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 |
||
7 | final class Query |
||
8 | { |
||
9 | private $classFqn; |
||
10 | private $expression; |
||
11 | private $orderings; |
||
12 | private $firstResult; |
||
13 | private $maxResults; |
||
14 | private $joins; |
||
15 | private $selects; |
||
16 | |||
17 | private function __construct( |
||
37 | |||
38 | public static function create( |
||
62 | |||
63 | public static function comparison(string $comparator, $value1, $value2): Comparison |
||
67 | |||
68 | public static function composite(string $type, ...$expressions): Composite |
||
72 | |||
73 | public static function join(string $type, string $alias) |
||
77 | |||
78 | public function getClassFqn(): string |
||
82 | |||
83 | public function hasExpression() |
||
87 | |||
88 | public function getExpression(): Expression |
||
92 | |||
93 | public function getOrderings(): array |
||
97 | |||
98 | public function getMaxResults() |
||
102 | |||
103 | public function getFirstResult() |
||
107 | |||
108 | public function getJoins(): array |
||
112 | |||
113 | public function getSelects(): array |
||
117 | } |
||
118 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.