示例#1
0
 private function render()
 {
     $this->prepareOutputDIrectory();
     $files = $this->score->getClasses();
     $methods = $this->score->getMethods() ?: array();
     $branches = $this->score->getBranches() ?: array();
     $paths = $this->score->getPaths() ?: array();
     $classes = array_unique(array_merge(array_keys($methods), array_keys($branches), array_keys($paths)));
     $coverageModel = new model\coverage();
     $coverageScore = new score\coverage();
     foreach ($classes as $className) {
         $classMethods = array_unique(array_merge(array_keys(isset($methods[$className]) ? $methods[$className] : array()), array_keys(isset($branches[$className]) ? $branches[$className] : array()), array_keys(isset($paths[$className]) ? $paths[$className] : array())));
         $classLines = file($files[$className]);
         $classModel = new model\coverage\klass($className);
         $classCoverage = new score\coverage();
         foreach ($classLines as $number => $line) {
             $classModel->addLine($number + 1, $line);
         }
         foreach ($classMethods as $methodName) {
             $methodLines = isset($methods[$className][$methodName]) ? $methods[$className][$methodName] : array();
             $methodBranches = isset($branches[$className][$methodName]) ? $branches[$className][$methodName] : array();
             $methodPaths = isset($paths[$className][$methodName]) ? $paths[$className][$methodName] : array();
             $reflectedMethod = new \reflectionMethod($className, $methodName);
             $startLineNumber = $reflectedMethod->getStartLine();
             $methodModel = new model\coverage\method($methodName, $methodBranches, $methodPaths);
             $methodCoverage = new score\coverage();
             $classModel->addLine($startLineNumber, rtrim($classLines[$startLineNumber - 1]), null, $methodName);
             $methodCoverage->linesAreAvailable($methodLines);
             $methodCoverage->pathsAreAvailable($methodPaths);
             foreach ($methodLines as $number => $hit) {
                 $classModel->addLine($number, rtrim($classLines[$number - 1]), $hit);
             }
             foreach ($methodBranches as $branch) {
                 $methodCoverage->branchIsAvailable($branch);
             }
             $methodCoverage->addToModel($methodModel);
             $methodModel->addToModel($classModel);
             $classCoverage = $classCoverage->merge($methodCoverage);
         }
         $classCoverage->addToModel($classModel);
         $classModel->addToModel($coverageModel);
         $this->classCodeCoverageIsAvailable($className, $classModel);
         $coverageScore = $coverageScore->merge($classCoverage);
     }
     $coverageScore->addToModel($coverageModel);
     $this->codeCoverageIsAvailable($coverageModel);
     $fs = new \Symfony\Component\Filesystem\Filesystem();
     $fs->mirror(__DIR__ . '/../../resources/html/assets', $this->outputDirectory . DIRECTORY_SEPARATOR . 'assets');
     $fs->mirror(__DIR__ . '/../../resources/html/fonts', $this->outputDirectory . DIRECTORY_SEPARATOR . 'fonts');
 }
示例#2
0
 public function addToModel(klass $class)
 {
     $class->addMethod($this->method, $this->coverage, $this->branches, $this->paths);
     return $this;
 }