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 |
||
| 9 | final class Query |
||
| 10 | { |
||
| 11 | private $classFqn; |
||
| 12 | private $expression; |
||
| 13 | private $orderings; |
||
| 14 | private $firstResult; |
||
| 15 | private $maxResults; |
||
| 16 | private $joins; |
||
| 17 | private $selects; |
||
| 18 | |||
| 19 | private function __construct( |
||
| 39 | |||
| 40 | public static function create( |
||
| 64 | |||
| 65 | public static function comparison(string $comparator, $value1, $value2): Comparison |
||
| 69 | |||
| 70 | public static function composite(string $type, ...$expressions): Composite |
||
| 74 | |||
| 75 | public static function join(string $type, string $alias) |
||
| 79 | |||
| 80 | public function getClassFqn(): string |
||
| 84 | |||
| 85 | public function hasExpression() |
||
| 89 | |||
| 90 | public function getExpression(): Expression |
||
| 94 | |||
| 95 | public function getOrderings(): array |
||
| 99 | |||
| 100 | public function getMaxResults() |
||
| 104 | |||
| 105 | public function getFirstResult() |
||
| 109 | |||
| 110 | public function getJoins(): array |
||
| 114 | |||
| 115 | public function getSelects(): array |
||
| 119 | } |
||
| 120 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.