@@ -105,28 +105,20 @@ final class CodeCoverage
105105 */
106106 private $ isInitialized = false ;
107107
108- /**
109- * @var Directory
110- */
111- private $ report ;
112-
113108 public function __construct (Driver $ driver , Filter $ filter )
114109 {
115110 $ this ->driver = $ driver ;
116111 $ this ->filter = $ filter ;
117112 $ this ->data = new ProcessedCodeCoverageData ;
113+ $ this ->wizard = new Wizard ;
118114 }
119115
120116 /**
121117 * Returns the code coverage information as a graph of node objects.
122118 */
123119 public function getReport (): Directory
124120 {
125- if ($ this ->report === null ) {
126- $ this ->report = (new Builder )->build ($ this );
127- }
128-
129- return $ this ->report ;
121+ return (new Builder )->build ($ this );
130122 }
131123
132124 /**
@@ -138,7 +130,6 @@ public function clear(): void
138130 $ this ->currentId = null ;
139131 $ this ->data = new ProcessedCodeCoverageData ;
140132 $ this ->tests = [];
141- $ this ->report = null ;
142133 }
143134
144135 /**
@@ -166,8 +157,7 @@ public function getData(bool $raw = false): ProcessedCodeCoverageData
166157 */
167158 public function setData (ProcessedCodeCoverageData $ data ): void
168159 {
169- $ this ->data = $ data ;
170- $ this ->report = null ;
160+ $ this ->data = $ data ;
171161 }
172162
173163 /**
@@ -292,8 +282,6 @@ public function append(RawCodeCoverageData $rawData, $id = null, bool $append =
292282
293283 $ this ->data ->markCodeAsExecutedByTestCase ($ id , $ rawData );
294284 }
295-
296- $ this ->report = null ;
297285 }
298286
299287 /**
@@ -309,8 +297,7 @@ public function merge(self $that): void
309297
310298 $ this ->data ->merge ($ that ->data );
311299
312- $ this ->tests = \array_merge ($ this ->tests , $ that ->getTests ());
313- $ this ->report = null ;
300+ $ this ->tests = \array_merge ($ this ->tests , $ that ->getTests ());
314301 }
315302
316303 public function enableTokenCaching (): void
@@ -608,7 +595,7 @@ private function performUnintentionallyCoveredCodeCheck(RawCodeCoverageData $dat
608595 foreach ($ data ->lineCoverage () as $ file => $ _data ) {
609596 foreach ($ _data as $ line => $ flag ) {
610597 if ($ flag === 1 && !isset ($ allowedLines [$ file ][$ line ])) {
611- $ unintentionallyCoveredUnits [] = $ this ->wizard () ->lookup ($ file , $ line );
598+ $ unintentionallyCoveredUnits [] = $ this ->wizard ->lookup ($ file , $ line );
612599 }
613600 }
614601 }
@@ -731,7 +718,7 @@ private function coverageToCodeUnits(RawCodeCoverageData $rawData): array
731718 foreach ($ rawData ->lineCoverage () as $ filename => $ lines ) {
732719 foreach ($ lines as $ line => $ flag ) {
733720 if ($ flag === 1 ) {
734- $ codeUnits [] = $ this ->wizard () ->lookup ($ filename , $ line );
721+ $ codeUnits [] = $ this ->wizard ->lookup ($ filename , $ line );
735722 }
736723 }
737724 }
@@ -745,19 +732,10 @@ private function linesToCodeUnits(array $data): array
745732
746733 foreach ($ data as $ filename => $ lines ) {
747734 foreach ($ lines as $ line ) {
748- $ codeUnits [] = $ this ->wizard () ->lookup ($ filename , $ line );
735+ $ codeUnits [] = $ this ->wizard ->lookup ($ filename , $ line );
749736 }
750737 }
751738
752739 return \array_unique ($ codeUnits );
753740 }
754-
755- private function wizard (): Wizard
756- {
757- if ($ this ->wizard === null ) {
758- $ this ->wizard = new Wizard ;
759- }
760-
761- return $ this ->wizard ;
762- }
763741}
0 commit comments