Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
21 | final class BuildedParameterResolver implements ParameterResolverInterface |
||
22 | { |
||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | private $defaultValue; |
||
27 | |||
28 | /** |
||
29 | * @var ConfigRepository |
||
30 | */ |
||
31 | private $config; |
||
32 | |||
33 | /** |
||
34 | * @var array |
||
35 | */ |
||
36 | private $parameters; |
||
37 | |||
38 | /** |
||
39 | * @var array |
||
40 | */ |
||
41 | private $resolved = []; |
||
|
|||
42 | |||
43 | public function __construct(array $parameters, ConfigRepository $config) |
||
49 | |||
50 | /** |
||
51 | * {@inheritdoc}array |
||
52 | */ |
||
53 | public function resolve($parameter) |
||
57 | |||
58 | /** |
||
59 | * @param mixed $value |
||
60 | * @param array $resolving |
||
61 | * |
||
62 | * @return mixed |
||
63 | * |
||
64 | * @throws ParameterCircularReferenceException |
||
65 | * @throws ParameterNotFoundException |
||
66 | */ |
||
67 | View Code Duplication | private function resolveValue($value, $resolving = []) |
|
83 | |||
84 | View Code Duplication | private function resolveArray(array $arrayValue, array $resolving) |
|
93 | |||
94 | /** |
||
95 | * @param $value |
||
96 | * @param $resolving |
||
97 | * |
||
98 | * @return array|mixed |
||
99 | * @throws ParameterCircularReferenceException |
||
100 | * @throws ParameterNotFoundException |
||
101 | */ |
||
102 | private function resolveString($value, array $resolving) |
||
126 | |||
127 | /** |
||
128 | * @param string $key |
||
129 | * |
||
130 | * @return string|int|bool|null |
||
131 | * @throws ParameterNotFoundException |
||
132 | */ |
||
133 | View Code Duplication | private function resolveEnvironmentValue($key) |
|
143 | } |
||
144 |
This check marks private properties in classes that are never used. Those properties can be removed.