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 |
||
| 5 | trait LengthTrait |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * @Exclude |
||
| 9 | * @var integer Specifies the maximum number of characters or list items allowed. Must be equal to or greater than zero |
||
| 10 | */ |
||
| 11 | private $maxLength = null; |
||
| 12 | /** |
||
| 13 | * @Exclude |
||
| 14 | * @var integer Specifies the minimum number of characters or list items allowed. Must be equal to or greater than zero |
||
| 15 | */ |
||
| 16 | private $minLength = null; |
||
| 17 | |||
| 18 | protected function setLengthFacet($value) |
||
| 23 | |||
| 24 | protected function setMinLengthFacet($value) |
||
| 29 | |||
| 30 | private function checkValidMinMaxLength($value, $min = 0) |
||
| 39 | |||
| 40 | protected function setMaxLengthFacet($value) |
||
| 45 | |||
| 46 | View Code Duplication | private function checkMaxLength($v) |
|
| 58 | |||
| 59 | View Code Duplication | private function checkMinLength($v) |
|
| 71 | } |
||
| 72 |