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 namespace Datium\Tools; |
||
| 6 | class DayOf { |
||
| 7 | |||
| 8 | protected $date_time; |
||
| 9 | |||
| 10 | protected $month; |
||
| 11 | |||
| 12 | protected $day; |
||
| 13 | |||
| 14 | protected $config; |
||
| 15 | |||
| 16 | protected $result; |
||
| 17 | |||
| 18 | protected $calendar_type; |
||
| 19 | |||
| 20 | protected $geregorian_DayofWeek; |
||
| 21 | |||
| 22 | public function __construct( $date_time, $calendar_type = 'gregorian' ) { |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Which day of year is current day. |
||
| 36 | * @since Aug, 03 2015 |
||
| 37 | * @return integer |
||
| 38 | */ |
||
| 39 | View Code Duplication | public function year() { |
|
| 46 | |||
| 47 | |||
| 48 | /** |
||
| 49 | * Which day of week is current day. |
||
| 50 | * @since Aug, 09 2015 |
||
| 51 | * @return integer |
||
| 52 | */ |
||
| 53 | View Code Duplication | public function week() { |
|
| 60 | |||
| 61 | } |
||
| 62 |