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.

SimpleFileSystemLoader   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 16.66%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 50
rs 10
c 0
b 0
f 0
ccs 3
cts 18
cp 0.1666

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B load() 0 29 5
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