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 StringSize extends Constraint |
|
8 | { |
||
9 | /** |
||
10 | * @var int |
||
11 | */ |
||
12 | protected $minSize; |
||
13 | |||
14 | /** |
||
15 | * @var int |
||
16 | */ |
||
17 | protected $maxSize; |
||
18 | |||
19 | public function __construct(int $minSize, int $maxSize = PHP_INT_MAX, string $errorMessage = null) |
||
28 | |||
29 | public function validate($content): bool |
||
43 | } |
||
44 |