task = $task; } public function handle(&$result, $next) { $key = 'sprints.'; $key .= ($this->task->sprint_id ?? 0).'.'; $key .= ($this->task->assignee_id ?? 0).'.'; $key .= $this->task->workflow_id . '.'; $key .= $this->task->status_id; $map = [ 'total' => 0, 'test' => 0, 'overdue' => 0, 'worked' => 0, // total worked in minute 'estimate' => 0, // estimate total ]; $node = Arr::get($result, $key, $map); $node['total'] = $node['total'] + 1; $node['test'] = $node['test'] + $result->ready_to_test; $node['overdue'] = $node['overdue'] + ($result->on_time? 0 : 1); Arr::set($result, $key, $node); return $next($result); } }