/** * Outputs some metrics info. * * @param Metrics $metrics A metrics instance. * @param array $options The options for the reporter, the options are: * - `'verbosity`' _integer|string_: The verbosity level: * - 1 : overall coverage value for the whole code. * - 2 : overall coverage by namespaces. * - 3 : overall coverage by classes. * - 4 : overall coverage by methods and functions. * - string : coverage for a fully namespaced (class/method/namespace) string. */ protected function _renderMetrics($metrics, $verbosity = 1) { $type = $metrics->type(); if ($verbosity === 2 && ($type === 'class' || $type === 'function')) { return; } if ($verbosity === 3 && ($type === 'function' || $type === 'method')) { return; } $name = $metrics->name(); $stats = $metrics->data(); $percent = number_format($stats['percent'], 2); $style = $this->_style($percent); $this->write(str_pad("Lines: {$percent}%", 15), $style); $this->write(trim(str_pad("({$stats['cloc']}/{$stats['lloc']})", 20) . "{$name}")); $this->write("\n"); if ($verbosity === 1) { return; } foreach ($metrics->childs() as $child) { $this->_renderMetrics($child, $verbosity); } }