public function terminate(ResultCollection $collection, ResultCollection $groupedResults)
{
$output = new BufferedOutput(OutputInterface::VERBOSITY_NORMAL, true);
// $output->write(str_pad("\x0D", 80, "\x20"));
// $output->writeln('');
// overview
$total = $this->bound->calculate($collection);
$output->writeln(sprintf('<info>%d</info> files have been analyzed. Read and understand these <info>%s</info> lines of code will take around <info>%s</info>.', sizeof($collection, COUNT_NORMAL), $total->getSum('loc'), $this->formatTime($total->getSum('time'))));
$output->writeln('<info>Average for each module:</info>');
$output->writeln('');
$hasOOP = null !== $total->getSum('instability');
$output->writeln('1 - Complexity');
$output->writeln('2 - Myer Distance: derivated from Cyclomatic complexity');
$output->writeln('3 - Maintainability');
$output->writeln('4 - LLOC: Number of logical lines of code');
$output->writeln('5 - Comment weight: measure the ratio between logical code and comments');
$output->writeln('6 - Vocabulary used in code');
$output->writeln('7 - Volume');
$output->writeln('8 - Bugs: Number of estimated bugs by file');
$output->writeln('9 - Difficulty of the code');
$output->writeln('A - LCOM: Lack of cohesion of methods measures the cohesiveness of a class');
$output->writeln('B - System complexity');
$output->writeln('C - Instability: Indicates the class is resilience to change');
$output->writeln('D - Abstractness: Number of abstract classes');
$output->writeln('E - Efferent coupling (CE): Number of classes that the class depend');
$output->writeln('F - Afferent coupling (CA): Number of classes affected by this class');
$output->writeln('');
$output->writeln('More details about metrics: http://www.phpmetrics.org/documentation/index.html');
$table = new \Symfony\Component\Console\Helper\Table($output);
$table->setHeaders(array_merge(array('1', '2', '3', '4', '5', '6', '7', '8', '9'), $hasOOP ? array('A', 'B', 'C', 'D', 'E', 'F') : array()));
foreach ($groupedResults as $key => $result) {
if ($result->getDepth() > 1) {
$table->addRow(new TableSeparator());
}
$table->addRow(array(new TableCell($result->getName(), array('colspan' => 15))));
$table->addRow(new TableSeparator());
$table->addRow(array_merge(array($this->getRow($result->getBounds(), 'cyclomaticComplexity', 'average', 0), $this->getRow($result->getBounds(), 'myerDistance', 'average', 0), $this->getRow($result->getBounds(), 'maintainabilityIndex', 'average', 0), $this->getRow($result->getBounds(), 'logicalLoc', 'sum', 0), $this->getRow($result->getBounds(), 'commentWeight', 'average', 0), $this->getRow($result->getBounds(), 'vocabulary', 'average', 0), $this->getRow($result->getBounds(), 'volume', 'average', 0), $this->getRow($result->getBounds(), 'bugs', 'sum', 2), $this->getRow($result->getBounds(), 'difficulty', 'average', 0)), $hasOOP ? array($this->getRow($result->getBounds(), 'lcom', 'average', 2), $this->getRow($result->getBounds(), 'rsysc', 'average', 2), $result->getInstability()->getInstability(), $result->getAbstractness()->getAbstractness(), $this->getRow($result->getBounds(), 'efferentCoupling', 'average', 2), $this->getRow($result->getBounds(), 'afferentCoupling', 'average', 2)) : array()));
}
$table->render();
return $output->fetch();
}