|
17 | 17 | use function sprintf; |
18 | 18 | use function str_pad; |
19 | 19 | use function strlen; |
20 | | -use SebastianBergmann\CodeCoverage\Node\Directory; |
| 20 | +use SebastianBergmann\CodeCoverage\CodeCoverage; |
21 | 21 | use SebastianBergmann\CodeCoverage\Node\File; |
22 | 22 | use SebastianBergmann\CodeCoverage\Util\Percentage; |
23 | 23 |
|
@@ -58,9 +58,12 @@ public function __construct(Thresholds $thresholds, bool $showUncoveredFiles = f |
58 | 58 | $this->showOnlySummary = $showOnlySummary; |
59 | 59 | } |
60 | 60 |
|
61 | | - public function process(Directory $report, bool $pathCoverage, bool $showColors = false): string |
| 61 | + public function process(CodeCoverage $coverage, bool $showColors = false): string |
62 | 62 | { |
| 63 | + $hasBranchCoverage = !empty($coverage->getData(true)->functionCoverage()); |
| 64 | + |
63 | 65 | $output = PHP_EOL . PHP_EOL; |
| 66 | + $report = $coverage->getReport(); |
64 | 67 |
|
65 | 68 | $colors = [ |
66 | 69 | 'header' => '', |
@@ -125,7 +128,7 @@ public function process(Directory $report, bool $pathCoverage, bool $showColors |
125 | 128 | $paths = ''; |
126 | 129 | $branches = ''; |
127 | 130 |
|
128 | | - if ($pathCoverage) { |
| 131 | + if ($hasBranchCoverage) { |
129 | 132 | $paths = sprintf( |
130 | 133 | ' Paths: %6s (%d/%d)', |
131 | 134 | Percentage::fromFractionAndTotal( |
@@ -177,11 +180,10 @@ public function process(Directory $report, bool $pathCoverage, bool $showColors |
177 | 180 | $output .= $this->format($colors['classes'], $padding, $classes); |
178 | 181 | $output .= $this->format($colors['methods'], $padding, $methods); |
179 | 182 |
|
180 | | - if ($pathCoverage) { |
| 183 | + if ($hasBranchCoverage) { |
181 | 184 | $output .= $this->format($colors['paths'], $padding, $paths); |
182 | 185 | $output .= $this->format($colors['branches'], $padding, $branches); |
183 | 186 | } |
184 | | - |
185 | 187 | $output .= $this->format($colors['lines'], $padding, $lines); |
186 | 188 |
|
187 | 189 | if ($this->showOnlySummary) { |
@@ -261,11 +263,10 @@ public function process(Directory $report, bool $pathCoverage, bool $showColors |
261 | 263 | $output .= PHP_EOL . $fullQualifiedPath . PHP_EOL |
262 | 264 | . ' ' . $methodColor . 'Methods: ' . $this->printCoverageCounts($classInfo['methodsCovered'], $classInfo['methodCount'], 2) . $resetColor . ' '; |
263 | 265 |
|
264 | | - if ($pathCoverage) { |
| 266 | + if ($hasBranchCoverage) { |
265 | 267 | $output .= ' ' . $pathsColor . 'Paths: ' . $this->printCoverageCounts($classInfo['pathsCovered'], $classInfo['pathsCount'], 3) . $resetColor . ' ' |
266 | 268 | . ' ' . $branchesColor . 'Branches: ' . $this->printCoverageCounts($classInfo['branchesCovered'], $classInfo['branchesCount'], 3) . $resetColor . ' '; |
267 | 269 | } |
268 | | - |
269 | 270 | $output .= ' ' . $linesColor . 'Lines: ' . $this->printCoverageCounts($classInfo['statementsCovered'], $classInfo['statementCount'], 3) . $resetColor; |
270 | 271 | } |
271 | 272 | } |
|
0 commit comments