Conditions | 3 |
Paths | 2 |
Total Lines | 13 |
Code Lines | 7 |
Lines | 13 |
Ratio | 100 % |
Tests | 7 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
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 |
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.