Exakat\Reports\Devoops::Dashboard PHP Method

Dashboard() protected method

protected Dashboard ( $title )
    protected function Dashboard($title)
    {
        $css = new \Stdclass();
        $css->displayTitles = true;
        $css->titles = array('Library', 'Folder', 'Home page');
        $css->readOrder = $css->titles;
        $titles = array('Code Smells' => 'Analyze', 'Dead Code' => 'Dead code', 'Security' => 'Security', 'Performances' => 'Performances');
        $list = Analyzer::getThemeAnalyzers($titles[$title]);
        $where = 'WHERE analyzer in ("' . implode('", "', $list) . '")';
        $res = $this->dump->query('SELECT severity, count(*) AS nb FROM results ' . $where . ' GROUP BY severity ORDER BY severity');
        $severities = array();
        while ($row = $res->fetchArray(\SQLITE3_ASSOC)) {
            $severities[$row['severity']] = array('severity' => $row['severity'], 'count' => $row['nb']);
        }
        $res = $this->dump->query('SELECT analyzer, count(*) AS nb, severity AS severity FROM results ' . $where . ' GROUP BY analyzer');
        $listBySeverity = array();
        $config = Config::factory();
        while ($row = $res->fetchArray(\SQLITE3_ASSOC)) {
            $ini = parse_ini_file($config->dir_root . '/human/en/' . $row['analyzer'] . '.ini');
            $listBySeverity[] = array('name' => $ini['name'], 'severity' => $row['severity'], 'count' => $row['nb']);
        }
        uasort($listBySeverity, function ($a, $b) {
            $s = array('Critical' => 6, 'Major' => 5, 'Middle' => 4, 'Minor' => 3, 'None' => 0);
            if ($s[$a['severity']] > $s[$b['severity']]) {
                return -1;
            } elseif ($s[$a['severity']] < $s[$b['severity']]) {
                return 1;
            } else {
                return 0;
            }
        });
        $listBySeverity = array_slice($listBySeverity, 0, 5);
        $res = $this->dump->query('SELECT file, count(*) AS nb FROM results ' . $where . ' GROUP BY file ORDER BY count(*) DESC LIMIT 5');
        $listByFile = array();
        while ($row = $res->fetchArray(\SQLITE3_ASSOC)) {
            $listByFile[] = array('name' => $row['file'], 'severity' => '', 'count' => $row['nb']);
        }
        $info = array('upLeft' => $severities, 'upRight' => '&nbsp;', 'downLeft' => $listBySeverity, 'downRight' => $listByFile);
        return $this->formatDashboard($info, $css);
    }