| Conditions | 5 |
| Paths | 6 |
| Total Lines | 23 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 5 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | 3 | protected function doDetect($filePath) |
|
| 22 | { |
||
| 23 | // mime_content_type supposedly used to be deprecated, but it seems it isn't anymore |
||
| 24 | // it may return false on failure. |
||
| 25 | 3 | if (function_exists('mime_content_type')) { |
|
| 26 | try { |
||
| 27 | 2 | $result = mime_content_type($filePath); |
|
| 28 | 1 | if ($result !== false) { |
|
| 29 | 1 | if (strpos($result, 'image/') === 0) { |
|
| 30 | 1 | return $result; |
|
| 31 | } else { |
||
| 32 | 1 | return false; |
|
| 33 | } |
||
| 34 | } |
||
| 35 | 1 | } catch (\Exception $e) { |
|
| 36 | // we are unstoppable! |
||
| 37 | |||
| 38 | // TODO: |
||
| 39 | // We should probably throw... - we will do in version 1.0.0 |
||
| 40 | //throw $e; |
||
| 41 | } |
||
| 42 | } |
||
| 43 | 2 | return null; |
|
| 44 | } |
||
| 46 |