| Conditions | 6 |
| Paths | 15 |
| Total Lines | 34 |
| Code Lines | 20 |
| Lines | 3 |
| Ratio | 8.82 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | public function build($project_id) |
||
| 29 | { |
||
| 30 | $metrics = []; |
||
| 31 | $total = 0; |
||
| 32 | $tasks = $this->taskFinderModel->getAll($project_id); |
||
|
|
|||
| 33 | $users = $this->projectUserRoleModel->getAssignableUsersList($project_id); |
||
| 34 | |||
| 35 | foreach ($tasks as $task) { |
||
| 36 | $user = isset($users[$task['owner_id']]) ? $users[$task['owner_id']] : $users[0]; |
||
| 37 | $total++; |
||
| 38 | |||
| 39 | if (!isset($metrics[$user])) { |
||
| 40 | $metrics[$user] = [ |
||
| 41 | 'nb_tasks' => 0, |
||
| 42 | 'percentage' => 0, |
||
| 43 | 'user' => $user, |
||
| 44 | ]; |
||
| 45 | } |
||
| 46 | |||
| 47 | $metrics[$user]['nb_tasks']++; |
||
| 48 | } |
||
| 49 | |||
| 50 | if ($total === 0) { |
||
| 51 | return []; |
||
| 52 | } |
||
| 53 | |||
| 54 | View Code Duplication | foreach ($metrics as &$metric) { |
|
| 55 | $metric['percentage'] = round(($metric['nb_tasks'] * 100) / $total, 2); |
||
| 56 | } |
||
| 57 | |||
| 58 | ksort($metrics); |
||
| 59 | |||
| 60 | return array_values($metrics); |
||
| 61 | } |
||
| 62 | } |
||
| 63 |
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.