XcfDetector   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 12
ccs 2
cts 2
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A detect() 0 3 2
1
<?php
2
3
namespace Selective\ImageType\Detector;
4
5
use Selective\ImageType\ImageFormat;
6
use Selective\ImageType\ImageType;
7
use Selective\ImageType\MimeType;
8
use SplFileObject;
9
10
/**
11
 * Detector.
12
 */
13
final class XcfDetector implements DetectorInterface
14
{
15
    /**
16
     * XCF - eXperimental Computing Facility (GIMP) identification.
17
     *
18
     * @param SplFileObject $file The image file
19
     *
20
     * @return ImageType|null The image type
21
     */
22 5
    public function detect(SplFileObject $file): ?ImageType
23
    {
24 5
        return $file->fread(9) === 'gimp xcf ' ? new ImageType(ImageFormat::XCF, MimeType::IMAGE_X_XCF) : null;
25
    }
26
}
27