protected function render() { $printer = new LimePrinter(new LimeColorizer()); foreach ($this->files as $file) { $totalLines = count($this->coveredCode[$file]) + count($this->uncoveredCode[$file]); $percent = count($this->coveredCode[$file]) * 100 / max($totalLines, 1); $relativeFile = $this->getRelativeFile($file); if ($percent == 100) { $style = LimePrinter::OK; } else { if ($percent >= 90) { $style = LimePrinter::INFO; } else { if ($percent <= 20) { $style = LimePrinter::NOT_OK; } else { $style = null; } } } $printer->printLine(sprintf("%-76s%3.0f%%", $relativeFile, $percent), $style); if ($this->options['verbose'] && $percent > 0 && $percent < 100) { $printer->printLine(sprintf("missing: %s", $this->formatRange($this->uncoveredCode[$file])), LimePrinter::COMMENT); } } $totalLines = $this->coveredLines + $this->uncoveredLines; $percent = $this->coveredLines * 100 / max($totalLines, 1); if ($percent <= 20) { $style = LimePrinter::NOT_OK; } else { $style = LimePrinter::HAPPY; } $printer->printLine(str_pad(sprintf(" Total Coverage: %3.0f%%", $percent), 80), $style); }
<?php /* * This file is part of the Lime framework. * * (c) Fabien Potencier <*****@*****.**> * (c) Bernhard Schussek <*****@*****.**> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ require_once dirname(__FILE__) . '/../../lib/LimeAutoloader.php'; LimeAutoloader::register(); $baseDir = realpath(dirname(__FILE__) . '/..'); $printer = new LimePrinter(new LimeColorizer()); $printer->printLine('Source Lines Of Code', LimePrinter::HAPPY); $fileLines = 0; $testLines = 0; $lexer = new LimeLexerCodeLines(); $suite = new LimeHarness(); $suite->registerGlob($baseDir . '/../lib/*.php'); $suite->registerGlob($baseDir . '/../lib/*/*.php'); $suite->registerGlob($baseDir . '/../lib/*/*/*.php'); $suite->registerGlob($baseDir . '/../lib/*/*/*/*.php'); $suite->registerGlob($baseDir . '/../lib/*/*/*/*/*.php'); foreach ($suite->getFiles() as $file) { $fileLines += count($lexer->parse($file)); } $printer->printLine(sprintf('Classes: %d', $fileLines)); $suite = new LimeHarness(); $suite->registerGlob($baseDir . '/unit/*.php');