GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 037104...b3593d )
by
unknown
10s
created

SimpleFileSystemLoader::load()   B

Complexity

Conditions 5
Paths 7

Size

Total Lines 29
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 8.439
c 0
b 0
f 0
ccs 0
cts 15
cp 0
cc 5
eloc 16
nc 7
nop 1
crap 30
1
<?php
2
namespace HtImgModule\Imagine\Loader;
3
4
use HtImgModule\Exception;
5
use HtImgModule\Binary\Binary;
6
7
class SimpleFileSystemLoader implements LoaderInterface
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $rootPath;
13
14
    /**
15
     * Constructor
16
     *
17
     * @param string
18
     */
19 4
    public function __construct($rootPath)
20
    {
21 4
        $this->rootPath = $rootPath;
22 4
    }
23
24
    /**
25
     * {@inheritDoc}
26
     */
27
    public function load($path)
28
    {
29
        if (false !== strpos($path, '../')) {
30
            throw new Exception\InvalidArgumentException(
31
                sprintf('Source image was searched with "%s" out side of the defined root path', $path)
32
            );
33
        }
34
35
        if ($this->rootPath === null) {
36
            $absolutePath = $path;
37
        } else {
38
            $absolutePath = $this->rootPath . '/' . ltrim($path, '/');
39
        }
40
41
        if (!file_exists($absolutePath)) {
42
            throw new Exception\ImageNotFoundException(sprintf('Source image not found in "%s"', $absolutePath));
43
        }
44
45
        $contents = file_get_contents($absolutePath);
46
47
        if (!function_exists('exif_imagetype')) {
48
            return $contents;
49
        }
50
51
        $extension = pathinfo($absolutePath, PATHINFO_EXTENSION);
52
        $mimeType  = image_type_to_mime_type(exif_imagetype($absolutePath));
53
54
        return new Binary($contents, $mimeType, $extension);
55
    }
56
}
57