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 | final class DateTimeHelper implements DateTimeHelperInterface |
|
| 8 | { |
||
| 9 | /** |
||
| 10 | * @inheritdoc} |
||
| 11 | */ |
||
| 12 | public function getDate(int $day, int $months = 0): \DateTimeInterface |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @inheritdoc} |
||
| 25 | */ |
||
| 26 | public function getFormattedDate(int $day, int $months = 0, $format = 'Y-m-d'): string |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @inheritdoc} |
||
| 33 | */ |
||
| 34 | public function getCurrentDate(): \DateTimeInterface |
||
| 38 | } |
||
| 39 |