| Conditions | 4 |
| Paths | 3 |
| Total Lines | 12 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | 1 | public static function isValidFilePath(?string $filePath): bool |
|
| 22 | { |
||
| 23 | 1 | if (!$filePath || !file_exists($filePath)) { |
|
| 24 | 1 | return false; |
|
| 25 | } |
||
| 26 | try { |
||
| 27 | 1 | $imageType = exif_imagetype($filePath); |
|
| 28 | 1 | } catch (\Exception $e) { |
|
| 29 | 1 | return false; |
|
| 30 | } |
||
| 31 | |||
| 32 | 1 | return \in_array($imageType, [IMAGETYPE_JPEG, IMAGETYPE_JPEG2000, IMAGETYPE_JP2, IMAGETYPE_PNG, IMAGETYPE_GIF], true); |
|
| 33 | } |
||
| 35 |