Exemple #1
0
 public function merge(score\coverage $coverage)
 {
     $paths = $coverage->getPaths();
     $branches = $coverage->getBranches();
     $classes = $coverage->getClasses();
     $methods = $coverage->getMethods();
     foreach ($methods as $class => $methods) {
         $reflectedClass = call_user_func($this->reflectionClassFactory, $class);
         if ($this->isExcluded($reflectedClass) === false) {
             if (isset($this->classes[$class]) === false) {
                 $this->classes[$class] = $classes[$class];
             }
             if (isset($paths[$class]) && isset($this->paths[$class]) === false) {
                 $this->paths[$class] = $paths[$class];
             }
             if (isset($branches[$class]) && isset($this->branches[$class]) === false) {
                 $this->branches[$class] = $branches[$class];
             }
             foreach ($methods as $method => $lines) {
                 if (isset($paths[$class]) === true) {
                     if (isset($this->paths[$class][$method]) === false) {
                         $this->paths[$class][$method] = $paths[$class][$method];
                     }
                     foreach ($paths[$class][$method] as $index => $path) {
                         if ($this->paths[$class][$method][$index]['hit'] < $path['hit']) {
                             $this->paths[$class][$method][$index]['hit'] = $path['hit'];
                         }
                     }
                 }
                 if (isset($branches[$class]) === true) {
                     if (isset($this->branches[$class][$method]) === false) {
                         $this->branches[$class][$method] = $branches[$class][$method];
                     }
                     foreach ($branches[$class][$method] as $index => $branch) {
                         if ($this->branches[$class][$method][$index]['hit'] < $branch['hit']) {
                             $this->branches[$class][$method][$index]['hit'] = $branch['hit'];
                         }
                         foreach ($branch['out'] as $outIndex => $outOp) {
                             if (isset($this->branches[$class][$method][$index]['out'][$outIndex]) === false) {
                                 $this->branches[$class][$method][$index]['out'][$outIndex] = $outOp;
                             }
                         }
                         foreach ($branch['out_hit'] as $outIndex => $hit) {
                             if (isset($this->branches[$class][$method][$index]['out_hit'][$outIndex]) === false) {
                                 $this->branches[$class][$method][$index]['out_hit'][$outIndex] = $hit;
                             } else {
                                 if ($this->branches[$class][$method][$index]['out_hit'][$outIndex] < $hit) {
                                     $this->branches[$class][$method][$index]['out_hit'][$outIndex] = $hit;
                                 }
                             }
                         }
                     }
                 }
                 if (isset($this->methods[$class][$method]) === true || $this->isExcluded($this->getDeclaringClass($reflectedClass->getMethod($method))) === false) {
                     foreach ($lines as $line => $call) {
                         if (isset($this->methods[$class][$method][$line]) === false || $this->methods[$class][$method][$line] < $call) {
                             $this->methods[$class][$method][$line] = $call;
                         }
                     }
                 }
             }
         }
     }
     return $this;
 }