phplinter\Report::toHtml PHP Метод

toHtml() публичный Метод

----------------------------------------------------------------------+
public toHtml ( $root, $report, $penaltys )
$report Array
$penaltys Array ----------------------------------------------------------------------+
    public function toHtml($root, $report, $penaltys)
    {
        $this->root = realpath($root);
        if (file_exists($this->output_dir)) {
            $output_dir = realpath($this->output_dir);
            if (!($this->options & OPT_OVERWRITE_REPORT)) {
                die("`{$output_dir}` not empty, aborting...\n");
            }
            if ($this->options & OPT_VERBOSE) {
                echo "Emptying `{$output_dir}`\n";
            }
            Path::del_recursive($this->output_dir);
        }
        if ($this->options & OPT_VERBOSE) {
            echo "Creating `{$this->output_dir}`\n";
        }
        if (!file_exists($this->output_dir) && !mkdir($this->output_dir, 0775)) {
            die("Unable to create `{$this->output_dir}`...\n");
        }
        $this->output_dir = realpath($this->output_dir);
        Path::write_file($this->output_dir . '/html_report.css', $this->css());
        foreach ($report as $file => $rep) {
            $out = '<div class="wrapper"><table border="1" cellpadding="0" cellspacing="0">';
            $content = '';
            foreach ($rep as $_) {
                $content .= '<tr>';
                $content .= '<td align="center" class="fl_';
                $content .= $_['flag'][0] . '">' . $_['flag'] . '</td>';
                $content .= '<td class="message">' . $_['message'] . '</td>';
                $content .= "<td class=\"where\">'`{$_['where']}` Line: {$_['line']}</td>\n";
                $content .= '</tr>';
            }
            $out .= '<tr>';
            $score = SCORE_FULL + $penaltys[$file];
            $class = $this->get_score_class($score);
            $out .= '<td colspan="2" align="center" class="' . $class . '">';
            $out .= sprintf('Score: %.2f', $score);
            $out .= '</td>';
            $parts = explode('/', $file);
            $rfile = array_pop($parts);
            $depth = count($parts);
            $path = $depth > 1 ? implode('/', $parts) : '';
            $path = substr(realpath($path), strlen($this->root));
            $out .= '<td class="filename">';
            $out .= "{$path}/{$rfile}";
            $out .= '</td></tr>';
            $out .= $content;
            $out .= '</table></div>';
            $dir = $this->output_dir . $path;
            if (!file_exists($dir) && !mkdir($dir, 0775, true)) {
                die("Unable to create `{$dir}`...\n");
            }
            $pp = explode('/', substr(realpath(implode('/', $parts)), strlen($this->root)));
            $ofile = $dir . '/' . strtr($rfile, './', '__') . '.html';
            if ($this->options & OPT_VERBOSE) {
                echo "Wrote to file `{$ofile}`\n";
            }
            Path::write_file($ofile, $this->html($out, count($pp)));
            $url['phplinter___file'] = $file;
            $url['phplinter___url'] = strtr($rfile, './', '__') . '.html';
            $url['phplinter___sort'] = strtolower($url['phplinter___url']);
            $this->parts($pp, $url, $urls);
        }
        $urls = $this->sort($urls);
        $this->output_indexes($urls, $penaltys);
    }