Passed
Push — master ( 2d60b9...33913d )
by Bjørn
01:46
created

src/Detectors/Stack.php (1 issue)

1
<?php
2
3
namespace ImageMimeTypeGuesser\Detectors;
4
5
class Stack extends AbstractDetector
6
{
7
8
    /**
9
     *  Try to detect mime type of image using all available detectors
10
     *  returns:
11
     *  - null  (if it cannot be determined)
12
     *  - false (if it can be determined that this is not an image)
13
     *  - mime  (if it is in fact an image, and type could be determined)
14
     *  @return  mime | null | false.
0 ignored issues
show
Documentation Bug introduced by
The doc comment mime | null | false. at position 4 could not be parsed: Unknown type name 'false.' at position 4 in mime | null | false..
Loading history...
15
     */
16
    protected function doDetect($filePath)
17
    {
18
        $detectors = [
19
            'ExifImageType',
20
            'GetImageSize',
21
            'FInfo',
22
            'MimeContentType'
23
        ];
24
25
        foreach ($detectors as $className) {
26
            $result = call_user_func(
27
                array("\\ImageMimeTypeGuesser\\Detectors\\" . $className, 'detect'),
28
                $filePath
29
            );
30
            if (!is_null($result)) {
31
                return $result;
32
            }
33
        }
34
35
        return;     // undetermined
36
    }
37
}
38