Skip to content

Commit

Permalink
AbstractGenerator::getCommonFilesPath() replaced by Helpers::findComm…
Browse files Browse the repository at this point in the history
…onDirectory()
  • Loading branch information
milo committed Feb 21, 2019
1 parent 8bbf089 commit eaaeb7b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
17 changes: 5 additions & 12 deletions src/CodeCoverage/Generators/AbstractGenerator.php
Expand Up @@ -9,6 +9,8 @@

namespace Tester\CodeCoverage\Generators;

use Tester\Helpers;


/**
* Code coverage report generator.
Expand Down Expand Up @@ -56,7 +58,7 @@ public function __construct(string $file, array $sources = [])
}, ARRAY_FILTER_USE_KEY);

if (!$sources) {
$sources = [self::getCommonFilesPath(array_keys($this->data))];
$sources = [Helpers::findCommonDirectory(array_keys($this->data))];

} else {
foreach ($sources as $source) {
Expand Down Expand Up @@ -118,19 +120,10 @@ protected function getSourceIterator(): \Iterator
}


/** @deprecated */
protected static function getCommonFilesPath(array $files): string
{
$path = reset($files);
for ($i = 0; $i < strlen($path); $i++) {
foreach ($files as $file) {
if (!isset($file[$i]) || $path[$i] !== $file[$i]) {
$path = substr($path, 0, $i);
break 2;
}
}
}

return rtrim(is_dir($path) ? $path : dirname($path), DIRECTORY_SEPARATOR);
return Helpers::findCommonDirectory($files);
}


Expand Down
4 changes: 3 additions & 1 deletion src/CodeCoverage/Generators/HtmlGenerator.php
Expand Up @@ -9,6 +9,8 @@

namespace Tester\CodeCoverage\Generators;

use Tester\Helpers;


/**
* Code coverage report generator.
Expand Down Expand Up @@ -70,7 +72,7 @@ private function parse(): void
}

$this->files = [];
$commonSourcesPath = self::getCommonFilesPath($this->sources) . DIRECTORY_SEPARATOR;
$commonSourcesPath = Helpers::findCommonDirectory($this->sources) . DIRECTORY_SEPARATOR;
foreach ($this->getSourceIterator() as $entry) {
$entry = (string) $entry;

Expand Down

0 comments on commit eaaeb7b

Please sign in to comment.