Skip to content

Commit c019dae

Browse files
Do not use private implementation detail of phpunit/php-code-coverage
1 parent 40fca2a commit c019dae

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/cli/PatchCoverageCommand.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use const PHP_EOL;
1313
use function is_file;
1414
use function printf;
15-
use SebastianBergmann\CodeCoverage\Percentage;
1615

1716
final class PatchCoverageCommand extends Command
1817
{
@@ -61,10 +60,10 @@ public function run(Arguments $arguments): int
6160
'%d / %d changed executable lines covered (%s)' . PHP_EOL,
6261
$patchCoverage['numChangedLinesThatWereExecuted'],
6362
$patchCoverage['numChangedLinesThatAreExecutable'],
64-
Percentage::fromFractionAndTotal(
63+
$this->percentage(
6564
$patchCoverage['numChangedLinesThatWereExecuted'],
6665
$patchCoverage['numChangedLinesThatAreExecutable']
67-
)->asFixedWidthString()
66+
)
6867
);
6968

7069
if (!empty($patchCoverage['changedLinesThatWereNotExecuted'])) {
@@ -85,4 +84,13 @@ public function run(Arguments $arguments): int
8584

8685
return 0;
8786
}
87+
88+
private function percentage(float $fraction, float $total): string
89+
{
90+
if ($total > 0) {
91+
return sprintf('%6.2F%%', ($fraction / $total) * 100);
92+
}
93+
94+
return '';
95+
}
8896
}

0 commit comments

Comments
 (0)