public static function getFilenameMediaType(string $filename, ?string $defaultMediaType = null):?string
    {
        if (preg_match('|\\.([^.]+)$|u', $filename, $matches)) {
            return self::getExtensionMediaType($matches[1]);
        }
        return $defaultMediaType;
    }
public static function getFilenameMediaType(string $filename, ?string $defaultMediaType = null):?string
    {
        if (preg_match('|\\.([^.]+)$|u', $filename, $matches)) {
            return self::getExtensionMediaType($matches[1]);
        }
        return $defaultMediaType;
    }
public static function getFilenameMediaType ( string $ filename , ? string $ defaultMediaType = null ) : ? string { if ( preg_match ( '|\\.([^.]+)$|u' , $ filename , $ matches ) ) { return self :: getExtensionMediaType ( $ matches [ 1 ] ) ; } return $ defaultMediaType ; }
Returns the media type for a given file name.

@param string $filename File name or path (must include an extension)
@param null|string $defaultMediaType Media type returned if the file's media type can not determined
@return null|string
@throws MediaTypesException
Returns the media type for a given file name .