original_string: public static function analyzeFile($path, $magic_db = null,
                                         $opts = array())
      {
          if (Horde_Util::extensionExists('fileinfo')) {
              $res = empty($magic_db)
                  ? finfo_open(FILEINFO_MIME)
                  : finfo_open(FILEINFO_MIME, $magic_db);
  
              if ($res) {
                  $type = trim(finfo_file($res, $path));
                  finfo_close($res);
  
                  /* Remove any additional information. */
                  if (empty($opts['nostrip'])) {
                      foreach (array(';', ',', '\\0') as $separator) {
                          if (($pos = strpos($type, $separator)) !== false) {
                              $type = rtrim(substr($type, 0, $pos));
                          }
                      }
  
                      if (preg_match('|^[a-z0-9]+/[.-a-z0-9]+$|i', $type)) {
                          return $type;
                      }
                  } else {
                      return $type;
                  }
              }
          }
  
          return false;
      }
code: public static function analyzeFile($path, $magic_db = null,
                                         $opts = array())
      {
          if (Horde_Util::extensionExists('fileinfo')) {
              $res = empty($magic_db)
                  ? finfo_open(FILEINFO_MIME)
                  : finfo_open(FILEINFO_MIME, $magic_db);
  
              if ($res) {
                  $type = trim(finfo_file($res, $path));
                  finfo_close($res);
  
                  /* Remove any additional information. */
                  if (empty($opts['nostrip'])) {
                      foreach (array(';', ',', '\\0') as $separator) {
                          if (($pos = strpos($type, $separator)) !== false) {
                              $type = rtrim(substr($type, 0, $pos));
                          }
                      }
  
                      if (preg_match('|^[a-z0-9]+/[.-a-z0-9]+$|i', $type)) {
                          return $type;
                      }
                  } else {
                      return $type;
                  }
              }
          }
  
          return false;
      }
code_tokens: public static function analyzeFile ( $ path , $ magic_db = null , $ opts = array ( ) ) { if ( Horde_Util :: extensionExists ( 'fileinfo' ) ) { $ res = empty ( $ magic_db ) ? finfo_open ( FILEINFO_MIME ) : finfo_open ( FILEINFO_MIME , $ magic_db ) ; if ( $ res ) { $ type = trim ( finfo_file ( $ res , $ path ) ) ; finfo_close ( $ res ) ; /* Remove any additional information. */ if ( empty ( $ opts [ 'nostrip' ] ) ) { foreach ( array ( ';' , ',' , '\\0' ) as $ separator ) { if ( ( $ pos = strpos ( $ type , $ separator ) ) !== false ) { $ type = rtrim ( substr ( $ type , 0 , $ pos ) ) ; } } if ( preg_match ( '|^[a-z0-9]+/[.-a-z0-9]+$|i' , $ type ) ) { return $ type ; } } else { return $ type ; } } } return false ; }
docstring: Attempt to determine the MIME type of an unknown file.
  
  @param string $path      The path to the file to analyze.
  @param string $magic_db  Path to the mime magic database.
  @param array $opts       Additional options:
  - nostrip: (boolean) Don't strip parameter information from MIME
  type string.
  DEFAULT: false
  
  @return mixed  The MIME type of the file. Returns false if the file
  type can not be determined.
docstring_tokens: Attempt to determine the MIME type of an unknown file .