src/Utilities/MimeTypes.php
public static function getMimeType($filePath)
    {
        /*
         * The file does not exist?
         * Nothing to do
         */
        if (!is_string($filePath) || !is_readable($filePath)) {
            return '';
        }

        // 1st possibility: the finfo class
        if (class_exists('finfo')) {
            $finfo = new \finfo();

            return $finfo->file($filePath, FILEINFO_MIME_TYPE);
        }

        // 2nd possibility: the mime_content_type function
        if (function_exists('mime_content_type')) {
            return mime_content_type($filePath);
        }

        // Oops, there is no possibility to read the mime type
        $template = 'Neither \'finfo\' class nor \'mime_content_type\' function exists. There is no way to read the'
            . ' mime type of file \'%s\'.';

        $message = sprintf($template, $filePath);

        throw new \RuntimeException($message);
    }
public static function getMimeType($filePath)
    {
        /*
         * The file does not exist?
         * Nothing to do
         */
        if (!is_string($filePath) || !is_readable($filePath)) {
            return '';
        }

        // 1st possibility: the finfo class
        if (class_exists('finfo')) {
            $finfo = new \finfo();

            return $finfo->file($filePath, FILEINFO_MIME_TYPE);
        }

        // 2nd possibility: the mime_content_type function
        if (function_exists('mime_content_type')) {
            return mime_content_type($filePath);
        }

        // Oops, there is no possibility to read the mime type
        $template = 'Neither \'finfo\' class nor \'mime_content_type\' function exists. There is no way to read the'
            . ' mime type of file \'%s\'.';

        $message = sprintf($template, $filePath);

        throw new \RuntimeException($message);
    }
public static function getMimeType ( $ filePath ) { /*
         * The file does not exist?
         * Nothing to do
         */ if ( ! is_string ( $ filePath ) || ! is_readable ( $ filePath ) ) { return '' ; } // 1st possibility: the finfo class if ( class_exists ( 'finfo' ) ) { $ finfo = new \ finfo ( ) ; return $ finfo -> file ( $ filePath , FILEINFO_MIME_TYPE ) ; } // 2nd possibility: the mime_content_type function if ( function_exists ( 'mime_content_type' ) ) { return mime_content_type ( $ filePath ) ; } // Oops, there is no possibility to read the mime type $ template = 'Neither \'finfo\' class nor \'mime_content_type\' function exists. There is no way to read the' . ' mime type of file \'%s\'.' ; $ message = sprintf ( $ template , $ filePath ) ; throw new \ RuntimeException ( $ message ) ; }
Returns mime type of given file

@param string $filePath Path of the file to check
@throws \RuntimeException
@return string
Returns mime type of given file