src/Util/MimeType.php
public static function getMimeTypeByFile(string $file)
    {
        if (!\is_file($file) || !\class_exists('\finfo', false)) {
            return null;
        }

        try {
            $finfo = new \finfo(FILEINFO_MIME_TYPE);

            return $finfo->file($file) ?: null;
            // @codeCoverageIgnoreStart
        } catch (\ErrorException $e) {
            // This is caused by an array to string conversion error.
            return null;
        }
    }
public static function getMimeTypeByFile(string $file)
    {
        if (!\is_file($file) || !\class_exists('\finfo', false)) {
            return null;
        }

        try {
            $finfo = new \finfo(FILEINFO_MIME_TYPE);

            return $finfo->file($file) ?: null;
            // @codeCoverageIgnoreStart
        } catch (\ErrorException $e) {
            // This is caused by an array to string conversion error.
            return null;
        }
    }
public static function getMimeTypeByFile ( string $ file ) { if ( ! \ is_file ( $ file ) || ! \ class_exists ( '\finfo' , false ) ) { return null ; } try { $ finfo = new \ finfo ( FILEINFO_MIME_TYPE ) ; return $ finfo -> file ( $ file ) ? : null ; // @codeCoverageIgnoreStart } catch ( \ ErrorException $ e ) { // This is caused by an array to string conversion error. return null ; } }
Detects MIME Type based on file.

@param string $file

@return string|null MIME Type or NULL if no mime type detected
Detects MIME Type based on file .