| Conditions | 13 |
| Paths | 14 |
| Total Lines | 52 |
| Code Lines | 40 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 144 | public function buildTitleWithAuthor($author, $eventName, array $eventData) |
||
| 145 | { |
||
| 146 | switch ($eventName) { |
||
| 147 | case TaskModel::EVENT_ASSIGNEE_CHANGE: |
||
| 148 | $assignee = $eventData['task']['assignee_name'] ?: $eventData['task']['assignee_username']; |
||
| 149 | |||
| 150 | if (!empty($assignee)) { |
||
| 151 | return l('%s changed the assignee of the task #%d to %s', $author, $eventData['task']['id'], $assignee); |
||
| 152 | } |
||
| 153 | |||
| 154 | return l('%s removed the assignee of the task %s', $author, l('#%d', $eventData['task']['id'])); |
||
| 155 | case TaskModel::EVENT_UPDATE: |
||
| 156 | return l('%s updated the task #%d', $author, $eventData['task']['id']); |
||
| 157 | case TaskModel::EVENT_CREATE: |
||
| 158 | return l('%s created the task #%d', $author, $eventData['task']['id']); |
||
| 159 | case TaskModel::EVENT_CLOSE: |
||
| 160 | return l('%s closed the task #%d', $author, $eventData['task']['id']); |
||
| 161 | case TaskModel::EVENT_OPEN: |
||
| 162 | return l('%s opened the task #%d', $author, $eventData['task']['id']); |
||
| 163 | case TaskModel::EVENT_MOVE_COLUMN: |
||
| 164 | return l( |
||
| 165 | '%s moved the task #%d to the column "%s"', |
||
| 166 | $author, |
||
| 167 | $eventData['task']['id'], |
||
| 168 | $eventData['task']['column_title'] |
||
| 169 | ); |
||
| 170 | case TaskModel::EVENT_MOVE_POSITION: |
||
| 171 | return l( |
||
| 172 | '%s moved the task #%d to the position %d in the column "%s"', |
||
| 173 | $author, |
||
| 174 | $eventData['task']['id'], |
||
| 175 | $eventData['task']['position'], |
||
| 176 | $eventData['task']['column_title'] |
||
| 177 | ); |
||
| 178 | case TaskModel::EVENT_MOVE_SWIMLANE: |
||
| 179 | if ($eventData['task']['swimlane_id'] == 0) { |
||
| 180 | return l('%s moved the task #%d to the first swimlane', $author, $eventData['task']['id']); |
||
| 181 | } |
||
| 182 | |||
| 183 | return l( |
||
| 184 | '%s moved the task #%d to the swimlane "%s"', |
||
| 185 | $author, |
||
| 186 | $eventData['task']['id'], |
||
| 187 | $eventData['task']['swimlane_name'] |
||
| 188 | ); |
||
| 189 | |||
| 190 | case TaskModel::EVENT_USER_MENTION: |
||
| 191 | return l('%s mentioned you in the task #%d', $author, $eventData['task']['id']); |
||
| 192 | default: |
||
| 193 | return ''; |
||
| 194 | } |
||
| 195 | } |
||
| 196 | |||
| 235 |
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.