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 | class TaskPositionModel extends Model |
||
20 | { |
||
21 | /** |
||
22 | * Move a task to another column or to another position. |
||
23 | * |
||
24 | * @param int $project_id Project id |
||
25 | * @param int $task_id Task id |
||
26 | * @param int $column_id Column id |
||
27 | * @param int $position Position (must be >= 1) |
||
28 | * @param int $swimlane_id Swimlane id |
||
29 | * @param bool $fire_events Fire events |
||
30 | * @param bool $onlyOpen Do not move closed tasks |
||
31 | * |
||
32 | * @return bool |
||
33 | */ |
||
34 | public function movePosition($project_id, $task_id, $column_id, $position, $swimlane_id = 0, $fire_events = true, $onlyOpen = true) |
||
62 | |||
63 | /** |
||
64 | * Move a task to another swimlane. |
||
65 | * |
||
66 | * @param int $project_id |
||
67 | * @param int $task_id |
||
68 | * @param int $position |
||
69 | * @param int $original_column_id |
||
70 | * @param int $new_column_id |
||
71 | * @param int $original_swimlane_id |
||
72 | * @param int $new_swimlane_id |
||
73 | * |
||
74 | * @return bool |
||
75 | */ |
||
76 | View Code Duplication | private function saveSwimlaneChange($project_id, $task_id, $position, $original_column_id, $new_column_id, $original_swimlane_id, $new_swimlane_id) |
|
86 | |||
87 | /** |
||
88 | * Move a task to another column. |
||
89 | * |
||
90 | * @param int $project_id |
||
91 | * @param int $task_id |
||
92 | * @param int $position |
||
93 | * @param int $swimlane_id |
||
94 | * @param int $original_column_id |
||
95 | * @param int $new_column_id |
||
96 | * |
||
97 | * @return bool |
||
98 | */ |
||
99 | View Code Duplication | private function saveColumnChange($project_id, $task_id, $position, $swimlane_id, $original_column_id, $new_column_id) |
|
109 | |||
110 | /** |
||
111 | * Move a task to another position in the same column. |
||
112 | * |
||
113 | * @param int $project_id |
||
114 | * @param int $task_id |
||
115 | * @param int $position |
||
116 | * @param int $column_id |
||
117 | * @param int $swimlane_id |
||
118 | * |
||
119 | * @return bool |
||
120 | */ |
||
121 | private function savePositionChange($project_id, $task_id, $position, $column_id, $swimlane_id) |
||
129 | |||
130 | /** |
||
131 | * Save all task positions for one column. |
||
132 | * |
||
133 | * @param int $project_id |
||
134 | * @param int $task_id |
||
135 | * @param int $position |
||
136 | * @param int $column_id |
||
137 | * @param int $swimlane_id |
||
138 | * |
||
139 | * @return bool |
||
140 | */ |
||
141 | private function saveTaskPositions($project_id, $task_id, $position, $column_id, $swimlane_id) |
||
180 | |||
181 | /** |
||
182 | * Update task timestamps. |
||
183 | * |
||
184 | * @param int $task_id |
||
185 | * |
||
186 | * @return bool |
||
187 | */ |
||
188 | private function saveTaskTimestamps($task_id) |
||
197 | |||
198 | /** |
||
199 | * Save new task position. |
||
200 | * |
||
201 | * @param int $task_id |
||
202 | * @param int $position |
||
203 | * @param int $column_id |
||
204 | * @param int $swimlane_id |
||
205 | * |
||
206 | * @return bool |
||
207 | */ |
||
208 | private function saveTaskPosition($task_id, $position, $column_id, $swimlane_id) |
||
224 | |||
225 | /** |
||
226 | * Fire events. |
||
227 | * |
||
228 | * @param array $task |
||
229 | * @param int $new_column_id |
||
230 | * @param int $new_position |
||
231 | * @param int $new_swimlane_id |
||
232 | */ |
||
233 | private function fireEvents(array $task, $new_column_id, $new_position, $new_swimlane_id) |
||
270 | } |
||
271 |
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.