CoverageCheckStyle::table()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 7
c 1
b 0
f 1
nc 1
nop 2
dl 0
loc 11
ccs 8
cts 8
cp 1
crap 1
rs 10
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