Conditions | 4 |
Paths | 3 |
Total Lines | 17 |
Code Lines | 9 |
Lines | 8 |
Ratio | 47.06 % |
Tests | 0 |
CRAP Score | 20 |
Changes | 0 |
1 | <?php |
||
53 | protected function resolveGetter(\ReflectionClass $reflection, string $name) |
||
54 | { |
||
55 | View Code Duplication | foreach (['get', 'is'] as $prefix) |
|
|
|||
56 | { |
||
57 | $getter = $prefix . ucfirst($name); |
||
58 | |||
59 | if ($reflection->hasMethod($getter) && $reflection->getMethod($getter)->isPublic()) { |
||
60 | return $getter; |
||
61 | } |
||
62 | } |
||
63 | |||
64 | throw new \LogicException(sprintf( |
||
65 | 'Getter-method for "%s" cannot be resolved automatically. ' . |
||
66 | 'Probably there is no get%2$s() or is%2$s() method or it is not public.', |
||
67 | $name, ucfirst($name) |
||
68 | )); |
||
69 | } |
||
70 | } |
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.