Skip to content

Commit 42245a7

Browse files
Fixed console output formatting
1 parent 9637996 commit 42245a7

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

player

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,16 @@ if (!is_file($playerFile)) {
1717
copy(__DIR__ . '/player.php.sample', $playerFile);
1818
}
1919

20+
function line(string $text, string $fill = ' '): string
21+
{
22+
return str_pad($text, 120, $fill, STR_PAD_RIGHT);
23+
}
24+
2025
$config = include __DIR__ . '/../../../player.php';
2126
$console = new ConsoleOutput();
22-
$separator = str_repeat('-', 120);
23-
$greanline = '<fg=black;bg=green>' . str_repeat(' ', 105) . '</>';
24-
$success = str_pad(' [OK] No leaking imports', 120, ' ', STR_PAD_RIGHT);
27+
$separator = line('', '-');
28+
$greanline = '<fg=black;bg=green>' . line('') . '</>';
29+
$success = line(' [OK] No leaking imports');
2530

2631
try {
2732
Player::create()->check($config);
@@ -43,9 +48,9 @@ try {
4348

4449
$total = array_reduce($exception->leaking, fn(int $reduced, array $imports) => $reduced + count($imports), 0);
4550

46-
$redline = '<fg=black;bg=red>' . str_repeat(' ', 120) . '</>';
51+
$redline = '<fg=black;bg=red>' . line('') . '</>';
4752
$message = sprintf(' [ERROR] Found %s unacceptable imports in %s classes', $total, count($exception->leaking));
48-
$error = str_pad($message, 120, ' ', STR_PAD_RIGHT);
53+
$error = line($message);
4954

5055
$console->writeln($redline);
5156
$console->writeln("<fg=white;bg=red>$error</>");

0 commit comments

Comments
 (0)