@@ -126,7 +126,7 @@ public function removeCoverageDataForFile(string $filename): void
126126 /**
127127 * @param int[] $lines
128128 */
129- public function keepCoverageDataOnlyForLines (string $ filename , array $ lines ): void
129+ public function keepLineCoverageDataOnlyForLines (string $ filename , array $ lines ): void
130130 {
131131 if (!isset ($ this ->lineCoverage [$ filename ])) {
132132 return ;
@@ -136,17 +136,25 @@ public function keepCoverageDataOnlyForLines(string $filename, array $lines): vo
136136 $ this ->lineCoverage [$ filename ],
137137 array_flip ($ lines )
138138 );
139+ }
139140
140- if (isset ($ this ->functionCoverage [$ filename ])) {
141- foreach ($ this ->functionCoverage [$ filename ] as $ functionName => $ functionData ) {
142- foreach ($ functionData ['branches ' ] as $ branchId => $ branch ) {
143- if (count (array_diff (range ($ branch ['line_start ' ], $ branch ['line_end ' ]), $ lines )) > 0 ) {
144- unset($ this ->functionCoverage [$ filename ][$ functionName ]['branches ' ][$ branchId ]);
141+ /**
142+ * @param int[] $lines
143+ */
144+ public function keepFunctionCoverageDataOnlyForLines (string $ filename , array $ lines ): void
145+ {
146+ if (!isset ($ this ->functionCoverage [$ filename ])) {
147+ return ;
148+ }
145149
146- foreach ($ functionData ['paths ' ] as $ pathId => $ path ) {
147- if (in_array ($ branchId , $ path ['path ' ], true )) {
148- unset($ this ->functionCoverage [$ filename ][$ functionName ]['paths ' ][$ pathId ]);
149- }
150+ foreach ($ this ->functionCoverage [$ filename ] as $ functionName => $ functionData ) {
151+ foreach ($ functionData ['branches ' ] as $ branchId => $ branch ) {
152+ if (count (array_diff (range ($ branch ['line_start ' ], $ branch ['line_end ' ]), $ lines )) > 0 ) {
153+ unset($ this ->functionCoverage [$ filename ][$ functionName ]['branches ' ][$ branchId ]);
154+
155+ foreach ($ functionData ['paths ' ] as $ pathId => $ path ) {
156+ if (in_array ($ branchId , $ path ['path ' ], true )) {
157+ unset($ this ->functionCoverage [$ filename ][$ functionName ]['paths ' ][$ pathId ]);
150158 }
151159 }
152160 }
0 commit comments