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

ConsoleFormatter::createNewStyle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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