/**
  * 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));
 }