Skip to content

Commit 61d610c

Browse files
Only pass ProcessedCodeCoverageData object and tests array to Builder::build() method
1 parent 6055ca6 commit 61d610c

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/CodeCoverage.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ public function __construct(Driver $driver, Filter $filter)
7575
*/
7676
public function getReport(): Directory
7777
{
78-
return (new Builder($this->analyser()))->build($this);
78+
return (new Builder($this->analyser()))->build(
79+
$this->getData(),
80+
$this->getTests()
81+
);
7982
}
8083

8184
/**

src/Node/Builder.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
use function str_replace;
2222
use function str_starts_with;
2323
use function substr;
24-
use SebastianBergmann\CodeCoverage\CodeCoverage;
2524
use SebastianBergmann\CodeCoverage\Data\ProcessedCodeCoverageData;
2625
use SebastianBergmann\CodeCoverage\StaticAnalysis\FileAnalyser;
2726

@@ -37,19 +36,20 @@ public function __construct(FileAnalyser $analyser)
3736
$this->analyser = $analyser;
3837
}
3938

40-
public function build(CodeCoverage $coverage): Directory
39+
/**
40+
* @psalm-param array<string, array{size: string, status: string}> $tests
41+
*/
42+
public function build(ProcessedCodeCoverageData $data, array $tests): Directory
4143
{
42-
$data = clone $coverage->getData(); // clone because path munging is destructive to the original data
44+
// clone because path munging is destructive to the original data
45+
$data = clone $data;
4346
$commonPath = $this->reducePaths($data);
44-
$root = new Directory(
45-
$commonPath,
46-
null
47-
);
47+
$root = new Directory($commonPath, null);
4848

4949
$this->addItems(
5050
$root,
5151
$this->buildDirectoryStructure($data),
52-
$coverage->getTests()
52+
$tests
5353
);
5454

5555
return $root;

0 commit comments

Comments
 (0)