| Conditions | 4 |
| Paths | 3 |
| Total Lines | 11 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | public static function isValidFilePath(?string $filePath): bool |
||
| 8 | { |
||
| 9 | if (!$filePath || !file_exists($filePath)) { |
||
| 10 | return false; |
||
| 11 | } |
||
| 12 | try { |
||
| 13 | $imageType = \exif_imagetype($filePath); |
||
| 14 | } catch (\Exception $e) { |
||
| 15 | return false; |
||
| 16 | } |
||
| 17 | return \in_array($imageType, [IMAGETYPE_JPEG, IMAGETYPE_JPEG2000, IMAGETYPE_PNG, IMAGETYPE_GIF], true); |
||
| 18 | } |
||
| 20 |