Kahlan\Reporter\Coverage::_renderMetricsReport PHP Method

_renderMetricsReport() protected method

Outputs some metrics reports built using ::_getMetricsReport().
protected _renderMetricsReport ( array $metricsReport, array $labelWidth, array $lineWidth, array $depth )
$metricsReport array An array of nested metrics reports extracted according some verbosity.
$labelWidth array The width column of the label column used for padding.
$lineWidth array The width column of the covered lines data used for padding.
$depth array The actual depth in the reporting to build tree prefix.
    protected function _renderMetricsReport($metricsReport, $labelWidth, $lineWidth, $depth)
    {
        $nbChilden = count($metricsReport);
        $index = 0;
        foreach ($metricsReport as $name => $data) {
            $isLast = $index === $nbChilden - 1;
            if ($isLast) {
                $this->_prefixes[$depth] = '└──';
            } else {
                $this->_prefixes[$depth] = '├──';
            }
            $metrics = $data['metrics'];
            $stats = $metrics->data();
            $percent = number_format($stats['percent'], 2);
            $style = $this->_style($percent);
            $prefix = join('', $this->_prefixes) . ' ';
            $diff = strlen($prefix) - strlen(utf8_decode($prefix));
            $type = $metrics->type();
            $color = $type === 'function' || $type === 'method' ? 'd' : '';
            $this->write($prefix);
            $this->write(str_pad($name, $labelWidth + $diff - strlen($prefix)), $color);
            $this->write('  ');
            $this->write(str_pad("{$stats['cloc']}", $lineWidth, ' ', STR_PAD_LEFT));
            $this->write(' / ');
            $this->write(str_pad("{$stats['lloc']}", $lineWidth, ' ', STR_PAD_LEFT));
            $this->write('     ');
            $this->write(str_pad("{$percent}%", 7, ' ', STR_PAD_LEFT), $style);
            $this->write("\n");
            if ($isLast) {
                $this->_prefixes[$depth] = '   ';
            } else {
                $this->_prefixes[$depth] = '│  ';
            }
            $this->_renderMetricsReport($data['children'], $labelWidth, $lineWidth, $depth + 1);
            $index++;
        }
        $this->_prefixes[$depth] = '';
    }