Kahlan\Reporter\Coverage::_getMetricsReport PHP Method

_getMetricsReport() protected method

Extract some metrics reports to display according to a verbosity parameter.
protected _getMetricsReport ( Metrics[] $children, $verbosity, array $depth, array $tab = 3, array &$maxWidth = null )
$children Metrics[] A array of metrics.
$depth array The actual depth in the reporting.
$tab array The size of the tab used for lablels.
$maxWidth array Will contain the maximum width obtained for labels.
    protected function _getMetricsReport($children, $verbosity, $depth = 0, $tab = 3, &$maxWidth = null)
    {
        $list = [];
        foreach ($children as $child) {
            $type = $child->type();
            if ($verbosity === 2 && $type !== 'namespace') {
                continue;
            }
            if ($verbosity === 3 && ($type === 'function' || $type === 'method')) {
                continue;
            }
            $name = $child->name();
            $pos = strrpos($name, '\\', $type === 'namespace' ? -2 : 0);
            $basename = substr($name, $pos !== false ? $pos + 1 : 0);
            $len = strlen($basename) + ($depth + 1) * $tab;
            if ($len > $maxWidth) {
                $maxWidth = $len;
            }
            $list[$basename] = ['metrics' => $child, 'children' => $this->_getMetricsReport($child->children(), $verbosity, $depth + 1, $tab, $maxWidth)];
        }
        return $list;
    }