EntityRepositoryManager   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 2
dl 0
loc 42
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A validatePlugin() 0 3 1
B validate() 0 19 6
1
<?php
2
/**
3
 * Polder Knowledge / entityservice-module (https://polderknowledge.com)
4
 *
5
 * @link https://github.com/polderknowledge/entityservice-module for the canonical source repository
6
 * @copyright Copyright (c) 2016 Polder Knowledge (https://polderknowledge.com)
7
 * @license https://github.com/polderknowledge/entityservice-module/blob/master/LICENSE.md MIT
8
 */
9
10
namespace PolderKnowledge\EntityService\Repository\Service;
11
12
use PolderKnowledge\EntityService\Exception\InvalidServiceException;
13
use PolderKnowledge\EntityService\Repository\Feature\DeletableInterface;
14
use PolderKnowledge\EntityService\Repository\Feature\FlushableInterface;
15
use PolderKnowledge\EntityService\Repository\Feature\ReadableInterface;
16
use PolderKnowledge\EntityService\Repository\Feature\WritableInterface;
17
use Zend\ServiceManager\AbstractPluginManager;
18
19
/**
20
 * Plugin manager for entity repositories used by entity services
21
 */
22
class EntityRepositoryManager extends AbstractPluginManager
23
{
24
    /**
25
     * {@inheritDoc}
26
     */
27 24
    public function __construct($configInstanceOrParentLocator = null, array $config = [])
28
    {
29 24
        parent::__construct($configInstanceOrParentLocator, $config);
30
31 24
        $this->autoAddInvokableClass = false;
32 24
    }
33
34
35
    // @codeCoverageIgnoreStart
36
    public function validatePlugin($plugin)
0 ignored issues
show
Unused Code introduced by
The parameter $plugin is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
37
    {
38
    }
39
    // @codeCoverageIgnoreEnd
40
41
    /**
42
     * {@inheritDoc}
43
     */
44 15
    public function validate($instance)
45
    {
46 15
        if ($instance instanceof DeletableInterface ||
47 12
            $instance instanceof FlushableInterface ||
48 9
            $instance instanceof ReadableInterface ||
49 15
            $instance instanceof WritableInterface) {
50 12
            return;
51
        }
52
53 3
        throw new InvalidServiceException(sprintf(
54 3
            'Plugin manager "%s" expected a type of %s, %s, %s or %s but received "%s"',
55 3
            __CLASS__,
56 3
            DeletableInterface::class,
57 3
            FlushableInterface::class,
58 3
            ReadableInterface::class,
59 3
            WritableInterface::class,
60 3
            is_object($instance) ? get_class($instance) : gettype($instance)
61 3
        ));
62
    }
63
}
64