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 |
||
13 | class EmojiController |
||
14 | { |
||
15 | private $auth; |
||
16 | |||
17 | public function __construct(Oauth $auth) |
||
21 | |||
22 | /** |
||
23 | * This method list all emojis. |
||
24 | * |
||
25 | * @param $response |
||
26 | * |
||
27 | * @return json $emojis |
||
28 | */ |
||
29 | public function listAllEmoji(Response $response) |
||
41 | |||
42 | /** |
||
43 | * This method get a single emoji. |
||
44 | * |
||
45 | * @param $response |
||
46 | * @param $args |
||
47 | * |
||
48 | * @return json $emoji |
||
49 | */ |
||
50 | public function getSingleEmoji(Response $response, $args) |
||
64 | |||
65 | /** |
||
66 | * This method creates a new emoji. |
||
67 | * |
||
68 | * @param $args |
||
69 | * |
||
70 | * @return json $response; |
||
71 | */ |
||
72 | public function createEmoji(Request $request, Response $response) |
||
103 | |||
104 | /** |
||
105 | * This method updates an emoji. |
||
106 | * |
||
107 | * @param $request |
||
108 | * @param $response |
||
109 | * |
||
110 | * @return json |
||
111 | */ |
||
112 | public function updateEmojiByPutVerb(Request $request, Response $response, $args) |
||
134 | |||
135 | /** |
||
136 | * This method updates an emoji partially. |
||
137 | * |
||
138 | * @param $request |
||
139 | * @param $response |
||
140 | * |
||
141 | * @return json |
||
142 | */ |
||
143 | public function updateEmojiByPatchVerb(Request $request, Response $response, $args) |
||
162 | |||
163 | /** |
||
164 | * This method deletes an emoji. |
||
165 | * |
||
166 | * @param $request |
||
167 | * @param $response |
||
168 | * @param $args |
||
169 | * |
||
170 | * @return json |
||
171 | */ |
||
172 | public function deleteEmoji(Request $request, Response $response, $args) |
||
187 | |||
188 | /** |
||
189 | * This method creates emoji keywords. |
||
190 | * |
||
191 | * @param $request |
||
192 | * @param $response |
||
193 | * @param $args |
||
194 | * |
||
195 | * @return $id |
||
196 | */ |
||
197 | View Code Duplication | public function createEmojiKeywords($emoji_id, $keywords) |
|
215 | |||
216 | /** |
||
217 | * This method format emoji result |
||
218 | * |
||
219 | * @param $emojis |
||
220 | * |
||
221 | * @return array $emojis |
||
222 | */ |
||
223 | public function formatEmoji(array $emojis) |
||
233 | |||
234 | /** |
||
235 | * This method authenticate and return user id. |
||
236 | */ |
||
237 | public function getCurrentUserId($request, $response) |
||
262 | |||
263 | /** |
||
264 | * This method checks for duplicate emoji |
||
265 | * |
||
266 | * @param $name |
||
267 | * |
||
268 | * @return boolean true |
||
269 | */ |
||
270 | public function checkForDuplicateEmoji($emojiName) |
||
286 | } |
||
287 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.