Example #1
0
 /**
  * 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);
     }
 }
Example #2
0
 /**
  * Outputs some metrics info for a given metric.
  *
  * @param Metrics $metrics A metrics instance.
  */
 protected function _renderMetric($metrics)
 {
     $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");
 }
Example #3
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);
 }