Completed
Push — develop ( f05cec...11f198 )
by Daniel
07:33
created

ImagineSupportedFilePath   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 13
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A isValidFilePath() 0 11 4
1
<?php
2
3
namespace Silverback\ApiComponentBundle\Validator;
4
5
class ImagineSupportedFilePath
6
{
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
    }
19
}
20