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