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 |
||
19 | View Code Duplication | class TicketDatetimesConnection implements ConnectionInterface |
|
20 | { |
||
21 | |||
22 | /** |
||
23 | * @var EEM_Datetime $model |
||
24 | */ |
||
25 | protected $model; |
||
26 | |||
27 | |||
28 | /** |
||
29 | * DatetimeConnection constructor. |
||
30 | * |
||
31 | * @param EEM_Datetime $model |
||
32 | */ |
||
33 | public function __construct(EEM_Datetime $model) |
||
37 | |||
38 | |||
39 | /** |
||
40 | * @return array |
||
41 | * @since $VID:$ |
||
42 | */ |
||
43 | public function config() |
||
54 | |||
55 | |||
56 | /** |
||
57 | * @param $entity |
||
58 | * @param $args |
||
59 | * @param $context |
||
60 | * @param $info |
||
61 | * @return array |
||
62 | * @throws Exception |
||
63 | * @since $VID:$ |
||
64 | */ |
||
65 | public function resolveConnection($entity, $args, $context, $info) |
||
70 | |||
71 | |||
72 | /** |
||
73 | * @param $id |
||
74 | * @param $args |
||
75 | * @param $context |
||
76 | * @param $info |
||
77 | * @return EE_Base_Class |
||
78 | * @since $VID:$ |
||
79 | */ |
||
80 | public function resolveNode($id, $args, $context, $info) |
||
84 | } |