/**
  * Get all user's captcha configuration.
  *
  * @return array
  * @throw \RuntimeException
  */
 public static function all()
 {
     $configPath = Path::getUserCaptchaConfigFilePath();
     if (!file_exists($configPath)) {
         throw new \RuntimeException(sprintf('File "%s" could not be found.', $configPath));
     }
     $captchaConfigs = (require $configPath);
     return $captchaConfigs;
 }
 /**
  * Load the captcha configuration defaults.
  *
  * @return void
  */
 private static function loadCaptchaConfigDefaults()
 {
     self::includeFile(Path::getCaptchaConfigDefaultsFilePath(), true);
 }
 /**
  * Get contents of Captcha resources (js, css, gif files).
  *
  * @return string
  */
 public function getResourceContents()
 {
     $fileName = $this->getUrlParameter('get');
     if (!preg_match('/^[a-z-]+\\.(css|gif|js)$/', $fileName)) {
         $this->badRequest('Invalid file name.');
     }
     $resourcePath = realpath(Path::getPublicDirPathInLibrary() . $fileName);
     if (!is_file($resourcePath)) {
         $this->badRequest(sprintf('File "%s" could not be found.', $fileName));
     }
     $fileInfo = pathinfo($resourcePath);
     $mimeTypes = ['css' => 'text/css', 'gif' => 'image/gif', 'js' => 'application/x-javascript'];
     return (new Response(file_get_contents($resourcePath), 200))->header('Content-Type', $mimeTypes[$fileInfo['extension']])->header('Content-Length', filesize($resourcePath));
 }