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 |
||
24 | class ProjectActivityHelper extends Base |
||
25 | { |
||
26 | /** |
||
27 | * Search events. |
||
28 | * |
||
29 | * @param string $search |
||
30 | * @param int $limit |
||
31 | * |
||
32 | * @return array |
||
33 | */ |
||
34 | public function searchEvents($search, $limit = 50) |
||
52 | |||
53 | /** |
||
54 | * Get project activity events. |
||
55 | * |
||
56 | * @param int $project_id |
||
57 | * @param int $limit |
||
58 | * |
||
59 | * @return array |
||
60 | */ |
||
61 | View Code Duplication | public function getProjectEvents($project_id, $limit = 50) |
|
72 | |||
73 | /** |
||
74 | * Get projects activity events. |
||
75 | * |
||
76 | * @param int[] $project_ids |
||
77 | * @param int $limit |
||
78 | * |
||
79 | * @return array |
||
80 | */ |
||
81 | View Code Duplication | public function getProjectsEvents(array $project_ids, $limit = 50) |
|
92 | |||
93 | /** |
||
94 | * Get task activity events. |
||
95 | * |
||
96 | * @param int $task_id |
||
97 | * |
||
98 | * @return array |
||
99 | */ |
||
100 | View Code Duplication | public function getTaskEvents($task_id) |
|
109 | } |
||
110 |
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.