ClonerPluginManager::validatePlugin()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 2
nop 1
1
<?php
2
/**
3
 * @link    https://github.com/nnx-framework/cloner
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace Nnx\Cloner;
7
8
use Zend\ServiceManager\AbstractPluginManager;
9
10
/**
11
 * Class ClonerPluginManager
12
 *
13
 * @package Nnx\Cloner
14
 */
15
class ClonerPluginManager extends AbstractPluginManager implements ClonerManagerInterface
16
{
17
    /**
18
     * Имя секции в конфиги приложения отвечающей за настройки менеджера
19
     *
20
     * @var string
21
     */
22
    const CONFIG_KEY = 'nnx_cloner';
23
24
    /**
25
     * {@inheritDoc}
26
     *
27
     * @throws Exception\RuntimeException
28
     */
29
    public function validatePlugin($plugin)
30
    {
31
        if ($plugin instanceof ClonerInterface) {
32
            return;
33
        }
34
35
        throw new Exception\RuntimeException(sprintf(
36
            'Plugin of type %s is invalid; must implement %s',
37
            (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
38
            ClonerInterface::class
39
        ));
40
    }
41
}
42