original_string: public function guessMimeType($filepath)
      {
          $magic_file = $this->getFileManager()->getMagicFile();
          $mimetype = finfo_file(finfo_open(FILEINFO_MIME_TYPE, $magic_file), $filepath);
  
          $extension = pathinfo($filepath, PATHINFO_EXTENSION);
          $match_extension = $this->matchMimetypeExtension($mimetype, $extension);
  
          //Use default mimetype guesser if it is not found
          if ($mimetype == "application/octet-stream" || !$match_extension) {
              $mimetype = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $filepath);
          }
  
          $this->setMimetype($mimetype);
  
          if (isset(self::$humanReadableTypes[$mimetype])) {
              $this->setReadableType(self::$humanReadableTypes[$mimetype]);
          } else {
              $this->setReadableType("Undefined");
          }
          $this->setFileclass($mimetype);
      }
code: public function guessMimeType($filepath)
      {
          $magic_file = $this->getFileManager()->getMagicFile();
          $mimetype = finfo_file(finfo_open(FILEINFO_MIME_TYPE, $magic_file), $filepath);
  
          $extension = pathinfo($filepath, PATHINFO_EXTENSION);
          $match_extension = $this->matchMimetypeExtension($mimetype, $extension);
  
          //Use default mimetype guesser if it is not found
          if ($mimetype == "application/octet-stream" || !$match_extension) {
              $mimetype = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $filepath);
          }
  
          $this->setMimetype($mimetype);
  
          if (isset(self::$humanReadableTypes[$mimetype])) {
              $this->setReadableType(self::$humanReadableTypes[$mimetype]);
          } else {
              $this->setReadableType("Undefined");
          }
          $this->setFileclass($mimetype);
      }
code_tokens: public function guessMimeType ( $ filepath ) { $ magic_file = $ this -> getFileManager ( ) -> getMagicFile ( ) ; $ mimetype = finfo_file ( finfo_open ( FILEINFO_MIME_TYPE , $ magic_file ) , $ filepath ) ; $ extension = pathinfo ( $ filepath , PATHINFO_EXTENSION ) ; $ match_extension = $ this -> matchMimetypeExtension ( $ mimetype , $ extension ) ; //Use default mimetype guesser if it is not found if ( $ mimetype == "application/octet-stream" || ! $ match_extension ) { $ mimetype = finfo_file ( finfo_open ( FILEINFO_MIME_TYPE ) , $ filepath ) ; } $ this -> setMimetype ( $ mimetype ) ; if ( isset ( self :: $ humanReadableTypes [ $ mimetype ] ) ) { $ this -> setReadableType ( self :: $ humanReadableTypes [ $ mimetype ] ) ; } else { $ this -> setReadableType ( "Undefined" ) ; } $ this -> setFileclass ( $ mimetype ) ; }
docstring: Try to guess the mimetypes first with a custom magic file.
  This fix the problems with wrong mime type detection.
  
  @param string $filepath
  @return mixed
docstring_tokens: Try to guess the mimetypes first with a custom magic file . This fix the problems with wrong mime type detection .