You are here

public function PHP_CodeCoverage::merge in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/php-code-coverage/src/CodeCoverage.php \PHP_CodeCoverage::merge()

Merges the data from another instance of PHP_CodeCoverage.

Parameters

PHP_CodeCoverage $that:

File

vendor/phpunit/php-code-coverage/src/CodeCoverage.php, line 341

Class

PHP_CodeCoverage
Provides collection functionality for PHP code coverage information.

Code

public function merge(PHP_CodeCoverage $that) {
  $this->filter
    ->setBlacklistedFiles(array_merge($this->filter
    ->getBlacklistedFiles(), $that
    ->filter()
    ->getBlacklistedFiles()));
  $this->filter
    ->setWhitelistedFiles(array_merge($this->filter
    ->getWhitelistedFiles(), $that
    ->filter()
    ->getWhitelistedFiles()));
  foreach ($that->data as $file => $lines) {
    if (!isset($this->data[$file])) {
      if (!$this->filter
        ->isFiltered($file)) {
        $this->data[$file] = $lines;
      }
      continue;
    }
    foreach ($lines as $line => $data) {
      if ($data !== null) {
        if (!isset($this->data[$file][$line])) {
          $this->data[$file][$line] = $data;
        }
        else {
          $this->data[$file][$line] = array_unique(array_merge($this->data[$file][$line], $data));
        }
      }
    }
  }
  $this->tests = array_merge($this->tests, $that
    ->getTests());
}