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 SubtaskHelper extends Base |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * Get the title. |
||
| 23 | * |
||
| 24 | * @param array $subtask |
||
| 25 | * |
||
| 26 | * @return string |
||
| 27 | */ |
||
| 28 | public function getTitle(array $subtask) |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Get the link to toggle subtask status. |
||
| 43 | * |
||
| 44 | * @param array $subtask |
||
| 45 | * @param int $project_id |
||
| 46 | * @param bool $refresh_table |
||
| 47 | * |
||
| 48 | * @return string |
||
| 49 | */ |
||
| 50 | public function toggleStatus(array $subtask, $project_id, $refresh_table = false) |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Display a select field of title. |
||
| 69 | * |
||
| 70 | * @param array $values Form values |
||
| 71 | * @param array $errors Form errors |
||
| 72 | * @param array $attributes |
||
| 73 | * |
||
| 74 | * @return string |
||
| 75 | */ |
||
| 76 | public function selectTitle(array $values, array $errors = [], array $attributes = []) |
||
| 85 | |||
| 86 | /** |
||
| 87 | * Display a select field of assignee. |
||
| 88 | * |
||
| 89 | * @param array $values Form values |
||
| 90 | * @param array $errors Form errors |
||
| 91 | * @param array $attributes |
||
| 92 | * |
||
| 93 | * @return string |
||
| 94 | */ |
||
| 95 | View Code Duplication | public function selectAssignee(array $users, array $values, array $errors = [], array $attributes = []) |
|
| 108 | |||
| 109 | /** |
||
| 110 | * Display a select field of time estimated. |
||
| 111 | * |
||
| 112 | * @param array $values Form values |
||
| 113 | * @param array $errors Form errors |
||
| 114 | * @param array $attributes |
||
| 115 | * |
||
| 116 | * @return string |
||
| 117 | */ |
||
| 118 | View Code Duplication | public function selectTimeEstimated(array $values, array $errors = [], array $attributes = []) |
|
| 128 | |||
| 129 | /** |
||
| 130 | * Display a select field of time spent. |
||
| 131 | * |
||
| 132 | * @param array $values Form values |
||
| 133 | * @param array $errors Form errors |
||
| 134 | * @param array $attributes |
||
| 135 | * |
||
| 136 | * @return string |
||
| 137 | */ |
||
| 138 | View Code Duplication | public function selectTimeSpent(array $values, array $errors = [], array $attributes = []) |
|
| 148 | } |
||
| 149 |
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@propertyannotation 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.