Conditions | 9 |
Paths | 11 |
Total Lines | 24 |
Code Lines | 12 |
Lines | 13 |
Ratio | 54.17 % |
Tests | 12 |
CRAP Score | 9.0368 |
Changes | 0 |
1 | <?php |
||
22 | 16 | protected static function validate(array $options) |
|
23 | { |
||
24 | 16 | if (array_key_exists('formatter', $options)) { |
|
25 | 8 | $formatter = $options['formatter']; |
|
26 | |||
27 | 8 | if (! ($formatter instanceof FormatterInterface || is_array($formatter))) { |
|
28 | 1 | throw InvalidOptionsException::forInvalidFormatter($formatter); |
|
29 | } |
||
30 | } |
||
31 | |||
32 | 15 | View Code Duplication | if (array_key_exists('processors', $options)) { |
|
|||
33 | 1 | $processors = $options['processors']; |
|
34 | |||
35 | 1 | if (! is_array($processors)) { |
|
36 | throw InvalidOptionsException::forInvalidProcessors($options['processors']); |
||
37 | } |
||
38 | |||
39 | 1 | foreach ($processors as $processor) { |
|
40 | 1 | if (! (is_callable($processor) || is_array($processor))) { |
|
41 | 1 | throw InvalidOptionsException::forInvalidProcessor($processor); |
|
42 | } |
||
43 | } |
||
44 | } |
||
45 | 15 | } |
|
46 | } |
||
47 |
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.