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 |
||
| 37 | View Code Duplication | class TicketDatetimesConnection implements ConnectionInterface |
|
| 38 | { |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @var EEM_Datetime $model |
||
| 42 | */ |
||
| 43 | protected $model; |
||
| 44 | |||
| 45 | |||
| 46 | /** |
||
| 47 | * DatetimeConnection constructor. |
||
| 48 | * |
||
| 49 | * @param EEM_Datetime $model |
||
| 50 | */ |
||
| 51 | public function __construct(EEM_Datetime $model) |
||
| 55 | |||
| 56 | |||
| 57 | /** |
||
| 58 | * @return array |
||
| 59 | * @since $VID:$ |
||
| 60 | */ |
||
| 61 | public function config() |
||
| 72 | |||
| 73 | |||
| 74 | /** |
||
| 75 | * @param $entity |
||
| 76 | * @param $args |
||
| 77 | * @param $context |
||
| 78 | * @param $info |
||
| 79 | * @return array |
||
| 80 | * @throws Exception |
||
| 81 | * @since $VID:$ |
||
| 82 | */ |
||
| 83 | public function resolveConnection($entity, $args, $context, $info) |
||
| 88 | |||
| 89 | |||
| 90 | /** |
||
| 91 | * @param $id |
||
| 92 | * @param $args |
||
| 93 | * @param $context |
||
| 94 | * @param $info |
||
| 95 | * @return EE_Base_Class |
||
| 96 | * @since $VID:$ |
||
| 97 | */ |
||
| 98 | public function resolveNode($id, $args, $context, $info) |
||
| 102 | } |