Total Complexity | 16 |
Total Lines | 58 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
12 | class GuessFromExtension |
||
13 | { |
||
14 | |||
15 | |||
16 | /** |
||
17 | * Make a wild guess based on file extension. |
||
18 | * |
||
19 | * - and I mean wild! |
||
20 | * |
||
21 | * Only most popular image types are recognized. |
||
22 | * Many are not. See this list: https://www.iana.org/assignments/media-types/media-types.xhtml |
||
23 | * - and the constants here: https://secure.php.net/manual/en/function.exif-imagetype.php |
||
24 | * |
||
25 | * If no mapping found, nothing is returned |
||
26 | * |
||
27 | * TODO: jp2, jpx, ... |
||
28 | * Returns: |
||
29 | * - mimetype (if file extension could be mapped to an image type), |
||
30 | * - false (if file extension could be mapped to a type known not to be an image type) |
||
31 | * - void (if file extension could not be mapped to any mime type, using our little list) |
||
32 | * |
||
33 | * @param string $filePath The path to the file |
||
34 | * @return string|false|void mimetype (if file extension could be mapped to an image type), |
||
35 | * false (if file extension could be mapped to a type known not to be an image type) |
||
36 | * or void (if file extension could not be mapped to any mime type, using our little list) |
||
37 | */ |
||
38 | public static function guess($filePath) |
||
74 |