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 |
||
| 15 | class DatePeriodFactory implements DatePeriodFactoryInterface |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * @var Iso8601Entity[] |
||
| 19 | */ |
||
| 20 | private static $iso8601Entity = []; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @param string $iso8601 |
||
| 24 | * @return Iso8601Entity |
||
| 25 | * @throws DatePeriodException |
||
| 26 | */ |
||
| 27 | 9 | public function createIso8601Entity($iso8601) |
|
| 43 | |||
| 44 | /** |
||
| 45 | * @param $iso8601 |
||
| 46 | * @param string $timezone |
||
| 47 | * @return \DatePeriod |
||
| 48 | */ |
||
| 49 | 4 | public function createDatePeriod($iso8601, $timezone = '') |
|
| 68 | } |
||
| 69 |