EventManagerPluginManager::validatePlugin()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 13
Ratio 100 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 13
loc 13
ccs 7
cts 7
cp 1
rs 9.4285
cc 3
eloc 7
nc 2
nop 1
crap 3
1
<?php
2
3
namespace Abacaphiliac\Zend\EventManager\PluginManager;
4
5
use Zend\EventManager\EventManagerInterface;
6
use Zend\ServiceManager\AbstractPluginManager;
7
use Zend\ServiceManager\Exception\RuntimeException;
8
9 View Code Duplication
class EventManagerPluginManager extends AbstractPluginManager
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
{
11
    /**
12
     * Validate the plugin
13
     *
14
     * Checks that the filter loaded is either a valid callback or an instance
15
     * of FilterInterface.
16
     *
17
     * @param  mixed $plugin
18
     * @return void
19
     * @throws RuntimeException if invalid
20
     */
21 4
    public function validatePlugin($plugin)
22
    {
23 4
        if ($plugin instanceof EventManagerInterface) {
24
            // we're ok.
25 3
            return;
26
        }
27
28 1
        throw new RuntimeException(sprintf(
29 1
            'Plugin of type %s is invalid; must implement %s',
30 1
            (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
31
            '\Zend\EventManager\EventManagerInterface'
32 1
        ));
33
    }
34
}
35