Completed
Pull Request — master (#94)
by Alessandro
04:59
created

ConsoleFormatter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 22
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A onEngineBeforeStart() 0 14 2
A createNewStyle() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Paraunit\Printer;
5
6
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
7
8
/**
9
 * Class ConsoleFormatter
10
 * @package Paraunit\Printer
11
 */
12
class ConsoleFormatter extends AbstractPrinter
13
{
14 21
    public function onEngineBeforeStart()
15
    {
16 21
        $formatter = $this->getOutput()->getFormatter();
17
18 21
        if ($formatter) {
19 21
            $formatter->setStyle('ok', $this->createNewStyle('green'));
20 21
            $formatter->setStyle('skip', $this->createNewStyle('yellow'));
21 21
            $formatter->setStyle('warning', $this->createNewStyle('yellow'));
22 21
            $formatter->setStyle('incomplete', $this->createNewStyle('blue'));
23 21
            $formatter->setStyle('fail', $this->createNewStyle('red'));
24 21
            $formatter->setStyle('error', $this->createNewStyle('red'));
25 21
            $formatter->setStyle('abnormal', $this->createNewStyle('magenta'));
26
        }
27
    }
28
29 21
    private function createNewStyle(string $color): OutputFormatterStyle
30
    {
31 21
        return new OutputFormatterStyle($color, null, ['bold', 'blink']);
32
    }
33
}
34