Conditions | 4 |
Paths | 5 |
Total Lines | 19 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 4.0466 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
23 | 1 | protected function doDetect($filePath) |
|
24 | { |
||
25 | // exif_imagetype is fast, however not available on all systems, |
||
26 | // It may return false. In that case we can rely on that the file is not an image (and return false) |
||
27 | 1 | if (function_exists('exif_imagetype')) { |
|
28 | try { |
||
29 | 1 | $imageType = exif_imagetype($filePath); |
|
30 | 1 | return ($imageType ? image_type_to_mime_type($imageType) : false); |
|
31 | 1 | } catch (\Exception $e) { |
|
32 | // Might for example get "Read error!" |
||
33 | // (for some reason, this happens on very small files) |
||
34 | // We handle such errors as indeterminable (null) |
||
35 | 1 | return null; |
|
36 | // well well, don't let this stop us |
||
37 | //echo $e->getMessage(); |
||
38 | //throw($e); |
||
39 | } |
||
40 | } |
||
41 | return null; |
||
42 | } |
||
44 |