Conditions | 5 |
Paths | 5 |
Total Lines | 33 |
Code Lines | 19 |
Lines | 9 |
Ratio | 27.27 % |
Tests | 22 |
CRAP Score | 5 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
29 | 16 | public function parse($id, $service, $fileName) |
|
30 | { |
||
31 | 16 | if (false === isset($service['autowiringTypes'])) { |
|
32 | 10 | return []; |
|
33 | } |
||
34 | |||
35 | 6 | View Code Duplication | if (false === is_array($service['autowiringTypes'])) { |
|
|||
36 | 2 | throw new InvalidArgumentException( |
|
37 | 1 | sprintf( |
|
38 | 2 | 'Parameter "autowiringTypes" must be an array for service "%s" in %s. Check your YAML syntax.', |
|
39 | 1 | $id, |
|
40 | $fileName |
||
41 | 1 | ) |
|
42 | 1 | ); |
|
43 | } |
||
44 | |||
45 | 4 | $autowiringTypes = []; |
|
46 | 4 | foreach ($service['autowiringTypes'] as $autowiringType) { |
|
47 | 4 | if (false === is_string($autowiringType)) { |
|
48 | 2 | throw new InvalidArgumentException( |
|
49 | 1 | sprintf( |
|
50 | 2 | 'A "autowiringType" entry must be a FQCN for service "%s" in %s. Check your YAML syntax.', |
|
51 | 1 | $id, |
|
52 | $fileName |
||
53 | 1 | ) |
|
54 | 1 | ); |
|
55 | } |
||
56 | |||
57 | 2 | $autowiringTypes[$autowiringType] = true; |
|
58 | 1 | } |
|
59 | |||
60 | 2 | return array_keys($autowiringTypes); |
|
61 | } |
||
62 | } |
||
63 |
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.