Пример #1
0
 /**
  * Outputs some metrics info where the metric is not the total coverage.
  *
  * @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)
 {
     $maxLabelWidth = null;
     if ($verbosity === 1) {
         return;
     }
     $metricsReport = $this->_getMetricsReport($metrics->children(), $verbosity, 0, 3, $maxLabelWidth);
     $name = $metrics->name() ?: '\\';
     $maxLabelWidth = max(strlen($name) + 1, $maxLabelWidth);
     $maxLabelWidth += 4;
     $stats = $metrics->data();
     $percent = number_format($stats['percent'], 2);
     $style = $this->_style($percent);
     $maxLineWidth = strlen($stats['lloc']);
     $this->write(str_repeat(' ', $maxLabelWidth));
     $this->write('  ');
     $this->write(str_pad('Lines', $maxLineWidth * 2 + 3, ' ', STR_PAD_BOTH));
     $this->write(str_pad('%', 12, ' ', STR_PAD_LEFT));
     $this->write("\n\n");
     $this->write(str_pad(' ' . $name, $maxLabelWidth));
     $this->write('  ');
     $this->write(str_pad("{$stats['cloc']}", $maxLineWidth, ' ', STR_PAD_LEFT));
     $this->write(' / ');
     $this->write(str_pad("{$stats['lloc']}", $maxLineWidth, ' ', STR_PAD_LEFT));
     $this->write('     ');
     $this->write(str_pad("{$percent}%", 7, ' ', STR_PAD_LEFT), $style);
     $this->write("\n");
     $this->_renderMetricsReport($metricsReport, $maxLabelWidth, $maxLineWidth, 0);
 }