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 |
||
| 11 | class Between extends AbstractCondition |
||
| 12 | { |
||
| 13 | protected |
||
| 14 | $column, |
||
|
1 ignored issue
–
show
|
|||
| 15 | $start, |
||
| 16 | $end; |
||
| 17 | |||
| 18 | 14 | public function __construct(Type $column, $start, $end) |
|
| 24 | |||
| 25 | 7 | public function toString(Escaper $escaper): string |
|
| 39 | |||
| 40 | 15 | public function isEmpty(): bool |
|
| 51 | |||
| 52 | 5 | View Code Duplication | private function escapeValue($value, Escaper $escaper) |
| 63 | } |
||
| 64 |
Only declaring a single property per statement allows you to later on add doc comments more easily.
It is also recommended by PSR2, so it is a common style that many people expect.