|
13 | 13 | use function count; |
14 | 14 | use function range; |
15 | 15 | use SebastianBergmann\CodeCoverage\CrapIndex; |
16 | | -use SebastianBergmann\CodeCoverage\StaticAnalysis\ExecutedFileAnalyser; |
17 | 16 | use SebastianBergmann\LinesOfCode\LinesOfCode; |
18 | 17 |
|
19 | 18 | /** |
@@ -126,15 +125,16 @@ final class File extends AbstractNode |
126 | 125 | */ |
127 | 126 | private $codeUnitsByLine = []; |
128 | 127 |
|
129 | | - public function __construct(string $name, AbstractNode $parent, array $lineCoverageData, array $functionCoverageData, array $testData, ExecutedFileAnalyser $executedFileAnalyser) |
| 128 | + public function __construct(string $name, AbstractNode $parent, array $lineCoverageData, array $functionCoverageData, array $testData, array $classes, array $traits, array $functions, LinesOfCode $linesOfCode) |
130 | 129 | { |
131 | 130 | parent::__construct($name, $parent); |
132 | 131 |
|
133 | 132 | $this->lineCoverageData = $lineCoverageData; |
134 | 133 | $this->functionCoverageData = $functionCoverageData; |
135 | 134 | $this->testData = $testData; |
| 135 | + $this->linesOfCode = $linesOfCode; |
136 | 136 |
|
137 | | - $this->calculateStatistics($executedFileAnalyser); |
| 137 | + $this->calculateStatistics($classes, $traits, $functions); |
138 | 138 | } |
139 | 139 |
|
140 | 140 | public function count(): int |
@@ -328,17 +328,15 @@ public function numberOfTestedFunctions(): int |
328 | 328 | return $this->numTestedFunctions; |
329 | 329 | } |
330 | 330 |
|
331 | | - private function calculateStatistics(ExecutedFileAnalyser $executedFileAnalyser): void |
| 331 | + private function calculateStatistics(array $classes, array $traits, array $functions): void |
332 | 332 | { |
333 | | - $this->linesOfCode = $executedFileAnalyser->linesOfCodeFor($this->pathAsString()); |
334 | | - |
335 | 333 | foreach (range(1, $this->linesOfCode->linesOfCode()) as $lineNumber) { |
336 | 334 | $this->codeUnitsByLine[$lineNumber] = []; |
337 | 335 | } |
338 | 336 |
|
339 | | - $this->processClasses($executedFileAnalyser->classesIn($this->pathAsString())); |
340 | | - $this->processTraits($executedFileAnalyser->traitsIn($this->pathAsString())); |
341 | | - $this->processFunctions($executedFileAnalyser->functionsIn($this->pathAsString())); |
| 337 | + $this->processClasses($classes); |
| 338 | + $this->processTraits($traits); |
| 339 | + $this->processFunctions($functions); |
342 | 340 |
|
343 | 341 | foreach (range(1, $this->linesOfCode->linesOfCode()) as $lineNumber) { |
344 | 342 | if (isset($this->lineCoverageData[$lineNumber])) { |
|
0 commit comments