protected static method

Reduces the results of multiple XDebug code coverage runs into a single 2D array of the aggregate line coverage density per file.


  • array $runs

    An array containing multiple runs of raw XDebug coverage data, where each array key is a file name, and its value is XDebug's coverage data for that file.

  • array $classMap

    An optional map with class names as array keys and corresponding file names as values. Used to filter the returned results, and will cause the array keys of the results to be class names instead of file names.




	protected static function _density($runs, $classMap = array()) {
		$results = array();

		foreach ($runs as $run) {
			foreach ($run as $file => $coverage) {
				if ($classMap) {
					if (!$class = array_search($file, $classMap)) {
					$file = $class;
				if (!isset($results[$file])) {
					$results[$file] = array();
				$coverage = array_filter($coverage, function($line) { return ($line === 1); });

				foreach ($coverage as $line => $isCovered) {
					if (!isset($results[$file][$line])) {
						$results[$file][$line] = 0;
		return $results;