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 |
||
22 | class SearchQuery extends AbstractQuery |
||
23 | { |
||
24 | /** |
||
25 | * @var array |
||
26 | */ |
||
27 | protected $attributes = [ |
||
28 | 'name' => 'Article list query', |
||
29 | 'description' => 'Returns a list of available articles', |
||
30 | ]; |
||
31 | |||
32 | /** |
||
33 | * @return ListOfType |
||
34 | */ |
||
35 | public function type(): ListOfType |
||
39 | |||
40 | /** |
||
41 | * @param $root |
||
42 | * @param array $args |
||
43 | * @return Collection |
||
44 | * @throws \InvalidArgumentException |
||
45 | */ |
||
46 | public function resolve($root, array $args = []): Collection |
||
63 | |||
64 | /** |
||
65 | * @param array $args |
||
66 | * @return int |
||
67 | */ |
||
68 | private function formatLimit(array $args = []): int |
||
74 | |||
75 | /** |
||
76 | * @return array |
||
77 | */ |
||
78 | View Code Duplication | public function queryArguments(): array |
|
95 | } |
||
96 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.