src/MimeType.php
public static function get(string $file, bool $guess = true): string
    {
        if($guess === true) {
            $extension = pathinfo($file, PATHINFO_EXTENSION);
            if(isset(self::$defaultMime[$extension])) {
                return self::$defaultMime[$extension];
            }
        }

        // Get mime using the file information functions
        $info = finfo_open(FILEINFO_MIME_TYPE);
        $mime = finfo_file($info, $file);
        finfo_close($info);

        if(false === $mime){
            $mime = 'application/octet-stream';
        }

        return $mime;
    }
public static function get(string $file, bool $guess = true): string
    {
        if($guess === true) {
            $extension = pathinfo($file, PATHINFO_EXTENSION);
            if(isset(self::$defaultMime[$extension])) {
                return self::$defaultMime[$extension];
            }
        }

        // Get mime using the file information functions
        $info = finfo_open(FILEINFO_MIME_TYPE);
        $mime = finfo_file($info, $file);
        finfo_close($info);

        if(false === $mime){
            $mime = 'application/octet-stream';
        }

        return $mime;
    }
public static function get ( string $ file , bool $ guess = true ) : string { if ( $ guess === true ) { $ extension = pathinfo ( $ file , PATHINFO_EXTENSION ) ; if ( isset ( self :: $ defaultMime [ $ extension ] ) ) { return self :: $ defaultMime [ $ extension ] ; } } // Get mime using the file information functions $ info = finfo_open ( FILEINFO_MIME_TYPE ) ; $ mime = finfo_file ( $ info , $ file ) ; finfo_close ( $ info ) ; if ( false === $ mime ) { $ mime = 'application/octet-stream' ; } return $ mime ; }
Returns the mime type of a file.

@param   string   $file   Full path to the file
@param   boolean  $guess  (optional) Set to false to disable mime type guessing
@return  string
Returns the mime type of a file .