1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* This file is part of PHPUnit Coverage Check. |
7
|
|
|
* |
8
|
|
|
* (c) Eric Sizemore <[email protected]> |
9
|
|
|
* (c) Richard Regeer <[email protected]> |
10
|
|
|
* |
11
|
|
|
* This source file is subject to the MIT license. For the full copyright, |
12
|
|
|
* license information, and credits/acknowledgements, please view the LICENSE |
13
|
|
|
* and README files that were distributed with this source code. |
14
|
|
|
*/ |
15
|
|
|
|
16
|
|
|
namespace Esi\CoverageCheck\Style; |
17
|
|
|
|
18
|
|
|
use Override; |
19
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
20
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
21
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @see SymfonyStyle |
25
|
|
|
*/ |
26
|
|
|
final class CoverageCheckStyle extends SymfonyStyle |
27
|
|
|
{ |
28
|
17 |
|
public function __construct( |
29
|
|
|
InputInterface $input, |
30
|
|
|
OutputInterface $output, |
31
|
|
|
private readonly int $tableWidth = 70 |
32
|
|
|
) { |
33
|
17 |
|
parent::__construct($input, $output); |
34
|
|
|
} |
35
|
|
|
|
36
|
8 |
|
#[Override] |
37
|
|
|
public function error(array|string $message, bool $onlyPercentage = false): void |
38
|
|
|
{ |
39
|
8 |
|
$this->block($message, ($onlyPercentage ? null : 'ERROR'), 'fg=white;bg=red', ' ', true); |
40
|
|
|
} |
41
|
|
|
|
42
|
2 |
|
#[Override] |
43
|
|
|
public function success(array|string $message, bool $onlyPercentage = false): void |
44
|
|
|
{ |
45
|
2 |
|
$this->block($message, ($onlyPercentage ? null : 'OK'), 'fg=black;bg=green', ' ', true); |
46
|
|
|
} |
47
|
|
|
|
48
|
4 |
|
#[Override] |
49
|
|
|
public function table(array $headers, array $rows): void |
50
|
|
|
{ |
51
|
4 |
|
$this->createTable() |
52
|
4 |
|
->setHeaders($headers) |
53
|
4 |
|
->setRows($rows) |
54
|
4 |
|
->setColumnMaxWidth(0, $this->tableWidth) |
55
|
4 |
|
->render() |
56
|
4 |
|
; |
57
|
|
|
|
58
|
4 |
|
$this->newLine(); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|