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 | View Code Duplication | class Range extends Constraint |
|
8 | { |
||
9 | /** |
||
10 | * @var int |
||
11 | */ |
||
12 | protected $min; |
||
13 | |||
14 | /** |
||
15 | * @var int |
||
16 | */ |
||
17 | protected $max; |
||
18 | |||
19 | public function __construct(int $min, int $max = PHP_INT_MAX, string $errorMessage = null) |
||
26 | |||
27 | public function validate($content): bool |
||
39 | } |
||
40 |