1 | <?php |
||
21 | class MimeType |
||
22 | { |
||
23 | /** @var array [<wrong type> => [<file .ext> => <right type>]] */ |
||
24 | private static $conversion = [ |
||
25 | 'application/octet-stream' => [ |
||
26 | 'mp4' => 'video/mp4', |
||
27 | ], |
||
28 | ]; |
||
29 | |||
30 | /** |
||
31 | * Get mime-type |
||
32 | * |
||
33 | * @param string $filepath File path on server to check the actual file |
||
34 | * @param string|null $name Original file name with original extension |
||
35 | * @return string Determined mime-type |
||
36 | */ |
||
37 | public static function get(string $filepath, ?string $name): string |
||
47 | |||
48 | /** |
||
49 | * Fix type based on filename extension |
||
50 | * |
||
51 | * @param string $type original mime-type |
||
52 | * @param string $filename path to file for filename |
||
53 | * @return string fixed mime-type |
||
54 | */ |
||
55 | private static function fixByFileExtension(string $type, string $filename): string |
||
79 | } |
||
80 |