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.

Paste::load()   B
last analyzed

Complexity

Conditions 5
Paths 9

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 8.8571
c 0
b 0
f 0
ccs 10
cts 10
cp 1
cc 5
eloc 10
nc 9
nop 1
crap 5
1
<?php
2
namespace HtImgModule\Imagine\Filter\Loader;
3
4
use Imagine\Image\ImagineInterface;
5
use HtImgModule\Imagine\Filter\Paste as PasteFilter;
6
use HtImgModule\Exception;
7
use Zend\View\Resolver\ResolverInterface;
8
9
class Paste implements LoaderInterface
10
{
11
    /**
12
     * @var ImagineInterface
13
     */
14
    protected $imagine;
15
16
    /**
17
     * @var ResolverInterface
18
     */
19
    protected $resolver;
20
21
    /**
22
     * Constructor
23
     *
24
     * @param ImagineInterface  $imagine
25
     * @param ResolverInterface $resolver
26
     */
27 6
    public function __construct(ImagineInterface $imagine, ResolverInterface $resolver)
28
    {
29 6
        $this->imagine = $imagine;
30 6
        $this->resolver = $resolver;
31 6
    }
32
33
    /**
34
     * {@inheritDoc}
35
     */
36 3
    public function load(array $options = [])
37
    {
38 3
        if (!isset($options['image'])) {
39 1
            throw new Exception\InvalidArgumentException('Option "image" is required.');
40
        }
41
42 2
        $x = isset($options['x']) ? $options['x'] : 0;
43 2
        $y = isset($options['y']) ? $options['y'] : 0;
44
45 2
        $path = $this->resolver->resolve($options['image']);
46
47 2
        if (!$path) {
48 1
            throw new Exception\RuntimeException(sprintf('Could not resolve %s', $options['image']));
49
        }
50
51 1
        $image = $this->imagine->open($path);
52
53 1
        return new PasteFilter($image, $x, $y);
54
    }
55
}
56