public function getIssuesBreakdown()
{
$receipt = array('Code Smells' => 'Analyze', 'Dead Code' => 'Dead code', 'Security' => 'Security', 'Performances' => 'Performances');
$data = array();
foreach ($receipt as $key => $categorie) {
$list = 'IN ("' . implode('", "', Analyzer::getThemeAnalyzers($categorie)) . '")';
$query = "SELECT sum(count) FROM resultsCounts WHERE analyzer {$list} AND count > 0";
$total = $this->sqlite->querySingle($query);
$data[] = array('label' => $key, 'value' => $total);
}
// ordonné DESC par valeur
uasort($data, function ($a, $b) {
if ($a['value'] > $b['value']) {
return -1;
} elseif ($a['value'] < $b['value']) {
return 1;
} else {
return 0;
}
});
$issuesHtml = '';
$dataScript = '';
foreach ($data as $key => $value) {
$issuesHtml .= '<div class="clearfix">
<div class="block-cell">' . $value['label'] . '</div>
<div class="block-cell text-center">' . $value['value'] . '</div>
</div>';
$dataScript .= $dataScript ? ', {label: "' . $value['label'] . '", value: ' . $value['value'] . '}' : '{label: "' . $value['label'] . '", value: ' . $value['value'] . '}';
}
$nb = 4 - count($data);
for ($i = 0; $i < $nb; ++$i) {
$html .= '<div class="clearfix">
<div class="block-cell"> </div>
<div class="block-cell text-center"> </div>
</div>';
}
return array('html' => $issuesHtml, 'script' => $dataScript);
}