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 | View Code Duplication | class EverydayRule implements HourIntervalRule |
|
| 12 | { |
||
| 13 | use HourlyIntervalRuleTrait; |
||
| 14 | use RandSecondsRuleTrait; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @param int $start |
||
| 18 | * @param int $end |
||
| 19 | * @param int $seconds |
||
| 20 | */ |
||
| 21 | 5 | public function __construct($start, $end, $seconds) |
|
| 27 | |||
| 28 | /** |
||
| 29 | * @param \DateTime $time |
||
| 30 | * |
||
| 31 | * @return bool |
||
| 32 | */ |
||
| 33 | 5 | public function isMatched(\DateTime $time) |
|
| 37 | } |
||
| 38 |