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 |
||
12 | class EventLoader extends AbstractLoader |
||
13 | { |
||
14 | /** |
||
15 | * Event prototype. |
||
16 | * @var ModelInterface $proto |
||
17 | */ |
||
18 | private $proto; |
||
19 | |||
20 | /** |
||
21 | * @var string $lifespan The lifespan of events. |
||
22 | */ |
||
23 | private $lifespan; |
||
24 | |||
25 | /** |
||
26 | * [proto description] |
||
27 | * @return [type] [description] |
||
|
|||
28 | */ |
||
29 | public function proto() |
||
37 | |||
38 | /** |
||
39 | * @return CollectionLoader |
||
40 | */ |
||
41 | View Code Duplication | public function all() |
|
49 | |||
50 | /** |
||
51 | * @return CollectionLoader |
||
52 | */ |
||
53 | View Code Duplication | public function published() |
|
62 | |||
63 | /** |
||
64 | * Fetch upcoming entries based on the lifespan or now. |
||
65 | * @return CollectionLoader |
||
66 | */ |
||
67 | public function upcoming() |
||
74 | |||
75 | /** |
||
76 | * Fetch upcoming entries based on the lifespan or now. |
||
77 | * @return CollectionLoader |
||
78 | */ |
||
79 | public function archive() |
||
86 | |||
87 | /** |
||
88 | * @param mixed $date The news date to filter |
||
89 | * [startDate, endDate] |
||
90 | * DateTimeInterface |
||
91 | * string. |
||
92 | * @return CollectionLoader |
||
93 | */ |
||
94 | View Code Duplication | public function since($date) |
|
102 | |||
103 | /** |
||
104 | * @param mixed $date The news date to filter |
||
105 | * [startDate, endDate] |
||
106 | * DateTimeInterface |
||
107 | * string. |
||
108 | * @return CollectionLoader |
||
109 | */ |
||
110 | View Code Duplication | public function to($date) |
|
118 | |||
119 | // ========================================================================== |
||
120 | // GETTERS |
||
121 | // ========================================================================== |
||
122 | |||
123 | /** |
||
124 | * @return mixed |
||
125 | */ |
||
126 | public function lifespan() |
||
130 | |||
131 | /** |
||
132 | * @return object |
||
133 | */ |
||
134 | public function objType() |
||
138 | |||
139 | // ========================================================================== |
||
140 | // SETTERS |
||
141 | // ========================================================================== |
||
142 | |||
143 | /** |
||
144 | * @param string $lifespan The lifespan of events. |
||
145 | * @return self Chainable |
||
146 | */ |
||
147 | public function setLifespan($lifespan) |
||
153 | |||
154 | /** |
||
155 | * @param object $objType The object type. |
||
156 | * @return self Chainable |
||
157 | */ |
||
158 | public function setObjType($objType) |
||
164 | |||
165 | // ========================================================================== |
||
166 | // UTILS |
||
167 | // ========================================================================== |
||
168 | |||
169 | /** |
||
170 | * @param mixed $date The date to convert. |
||
171 | * @return DateTime |
||
172 | */ |
||
173 | private function parseAsDate($date) |
||
181 | } |
||
182 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.