|
10 | 10 | namespace SebastianBergmann\CodeCoverage\Report;
|
11 | 11 |
|
12 | 12 | use const PHP_EOL;
|
13 |
| -use function array_map; |
14 | 13 | use function date;
|
15 | 14 | use function ksort;
|
16 |
| -use function max; |
17 | 15 | use function sprintf;
|
18 |
| -use function str_pad; |
19 |
| -use function strlen; |
20 | 16 | use SebastianBergmann\CodeCoverage\CodeCoverage;
|
21 | 17 | use SebastianBergmann\CodeCoverage\Node\File;
|
22 | 18 | use SebastianBergmann\CodeCoverage\Util\Percentage;
|
@@ -160,31 +156,28 @@ public function process(CodeCoverage $coverage, bool $showColors = false): strin
|
160 | 156 | $report->numberOfExecutableLines(),
|
161 | 157 | );
|
162 | 158 |
|
163 |
| - $padding = max(array_map('strlen', [$classes, $methods, $lines])); |
164 |
| - |
165 | 159 | if ($this->showOnlySummary) {
|
166 |
| - $title = 'Code Coverage Report Summary:'; |
167 |
| - $padding = max($padding, strlen($title)); |
| 160 | + $title = 'Code Coverage Report Summary:'; |
168 | 161 |
|
169 |
| - $output .= $this->format($colors['header'], $padding, $title); |
| 162 | + $output .= $this->format($colors['header'], $title); |
170 | 163 | } else {
|
171 | 164 | $date = date(' Y-m-d H:i:s');
|
172 | 165 | $title = 'Code Coverage Report:';
|
173 | 166 |
|
174 |
| - $output .= $this->format($colors['header'], $padding, $title); |
175 |
| - $output .= $this->format($colors['header'], $padding, $date); |
176 |
| - $output .= $this->format($colors['header'], $padding, ''); |
177 |
| - $output .= $this->format($colors['header'], $padding, ' Summary:'); |
| 167 | + $output .= $this->format($colors['header'], $title); |
| 168 | + $output .= $this->format($colors['header'], $date); |
| 169 | + $output .= $this->format($colors['header'], ''); |
| 170 | + $output .= $this->format($colors['header'], ' Summary:'); |
178 | 171 | }
|
179 | 172 |
|
180 |
| - $output .= $this->format($colors['classes'], $padding, $classes); |
181 |
| - $output .= $this->format($colors['methods'], $padding, $methods); |
| 173 | + $output .= $this->format($colors['classes'], $classes); |
| 174 | + $output .= $this->format($colors['methods'], $methods); |
182 | 175 |
|
183 | 176 | if ($hasBranchCoverage) {
|
184 |
| - $output .= $this->format($colors['paths'], $padding, $paths); |
185 |
| - $output .= $this->format($colors['branches'], $padding, $branches); |
| 177 | + $output .= $this->format($colors['paths'], $paths); |
| 178 | + $output .= $this->format($colors['branches'], $branches); |
186 | 179 | }
|
187 |
| - $output .= $this->format($colors['lines'], $padding, $lines); |
| 180 | + $output .= $this->format($colors['lines'], $lines); |
188 | 181 |
|
189 | 182 | if ($this->showOnlySummary) {
|
190 | 183 | return $output . PHP_EOL;
|
@@ -304,10 +297,10 @@ private function printCoverageCounts(int $numberOfCoveredElements, int $totalNum
|
304 | 297 | sprintf($format, $totalNumberOfElements) . ')';
|
305 | 298 | }
|
306 | 299 |
|
307 |
| - private function format(string $color, int $padding, false|string $string): string |
| 300 | + private function format(string $color, false|string $string): string |
308 | 301 | {
|
309 | 302 | $reset = $color ? self::COLOR_RESET : '';
|
310 | 303 |
|
311 |
| - return $color . str_pad((string) $string, $padding) . $reset . PHP_EOL; |
| 304 | + return $color . (string) $string . $reset . PHP_EOL; |
312 | 305 | }
|
313 | 306 | }
|
0 commit comments