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' ) { |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Which day of year is current day. |
||
| 40 | * @since Aug, 03 2015 |
||
| 41 | * @return integer |
||
| 42 | */ |
||
| 43 | public function year() { |
||
| 50 | |||
| 51 | |||
| 52 | /** |
||
| 53 | * Which day of week is current day. |
||
| 54 | * @since Aug, 09 2015 |
||
| 55 | * @return integer |
||
| 56 | */ |
||
| 57 | public function week() { |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @since Sept, 14 2015 |
||
| 86 | * @return integer |
||
| 87 | */ |
||
| 88 | View Code Duplication | protected function persian_day_of_week() { |
|
| 99 | |||
| 100 | /** |
||
| 101 | * @since Sept, 14 2015 |
||
| 102 | * @return integer |
||
| 103 | */ |
||
| 104 | View Code Duplication | protected function islamic_day_of_week() { |
|
| 116 | |||
| 117 | |||
| 118 | } |
||
| 119 | ?> |
||
| 120 |