Completed
Push — master ( 269014...5eca8b )
by Андрей
02:50 queued 54s
created

EntryNameResolverManager   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 41
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A validatePlugin() 0 12 3
1
<?php
2
/**
3
 * @link    https://github.com/nnx-framework/entry-name-resolver
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace Nnx\EntryNameResolver;
7
8
use Interop\Container\ContainerInterface;
9
use Zend\ServiceManager\AbstractPluginManager;
10
use Zend\ServiceManager\ConfigInterface;
11
use Zend\ServiceManager\Exception;
12
13
/**
14
 * Class EntryNameResolverManager
15
 *
16
 * @package Nnx\EntryNameResolver\EntryNameResolver
17
 *
18
 * @method EntryNameResolverInterface get($id)
19
 */
20
class EntryNameResolverManager extends AbstractPluginManager implements ContainerInterface
21
{
22
    /**
23
     * Имя секции в конфиги приложения отвечающей за настройки менеджера
24
     *
25
     * @var string
26
     */
27
    const CONFIG_KEY = 'nnx_container_entry_name_resolver';
28
29
    /**
30
     * EntryNameResolverManager constructor.
31
     *
32
     * @param null|ConfigInterface $configuration
33
     *
34
     * @throws \Zend\ServiceManager\Exception\RuntimeException
35
     */
36
    public function __construct(ConfigInterface $configuration = null)
37
    {
38
        parent::__construct($configuration);
39
        $this->setShareByDefault(false);
40
    }
41
42
43
    /**
44
     * {@inheritDoc}
45
     *
46
     * @throws Exception\RuntimeException
47
     */
48
    public function validatePlugin($plugin)
49
    {
50
        if ($plugin instanceof EntryNameResolverInterface) {
51
            return;
52
        }
53
54
        throw new Exception\RuntimeException(sprintf(
55
            'Plugin of type %s is invalid; must implement %s',
56
            (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
57
            EntryNameResolverInterface::class
58
        ));
59
    }
60
}
61