getProject(); } else { throw new \RuntimeException(); } $stats = []; $places = $this->taskLifecycleStateMachine->getDefinition()->getPlaces(); $metas = $this->taskLifecycleStateMachine->getMetadataStore(); if (empty($places)) { return $stats; } foreach ($places as $place => $id) { $stats[$place] = array_merge($metas->getPlaceMetadata($place), [ 'value' => 0, ]); } $max = 0; foreach ($project->getTasks() as $task) { ++$stats[$task->getStatus()]['value']; ++$max; } if (0 === $max) { return $stats; } $stats = array_map(function ($data) use ($max) { $data['max'] = $max; $data['percentage'] = ((float) $data['value'] * 100.0) / $max; return $data; }, $stats); return $stats; } }