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.

LoaderPluginManager::validate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
ccs 7
cts 7
cp 1
cc 2
eloc 6
nc 2
nop 1
crap 2
1
<?php
2
namespace HtImgModule\Imagine\Loader;
3
4
use HtImgModule\Factory\Imagine\Loader\FileSystemLoaderFactory;
5
use HtImgModule\Factory\Imagine\Loader\SimpleFileSystemLoaderFactory;
6
use Zend\ServiceManager\AbstractPluginManager;
7
use HtImgModule\Exception;
8
use Zend\ServiceManager\Exception\InvalidServiceException;
9
10
class LoaderPluginManager extends AbstractPluginManager
11
{
12
    protected $instanceOf = LoaderInterface::class;
13
14
    protected $aliases = [
15
        'FileSystem' => 'filesystem',
16
        'Simple' => 'simple',
17
    ];
18
19
    protected $factories = [
20
        'filesystem' => FileSystemLoaderFactory::class,
21
        'simple'     => SimpleFileSystemLoaderFactory::class,
22
    ];
23
24
    protected $shared = [
25
        'simple' => false
26
    ];
27
28 2
    public function validate($instance)
29
    {
30 2
        if (! $instance instanceof $this->instanceOf) {
31 1
            throw new InvalidServiceException(sprintf(
32 1
                'Invalid plugin "%s" created; not an instance of %s',
33 1
                get_class($instance),
34 1
                $this->instanceOf
35
            ));
36
        }
37 1
    }
38
39 2
    public function validatePlugin($instance)
40
    {
41
        try {
42 2
            $this->validate($instance);
43 1
        } catch (InvalidServiceException $e) {
44 1
            throw new Exception\InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
45
        }
46 1
    }
47
}
48