Completed
Push — output_parsers_refactor ( d2cb12...a7c18a )
by Alessandro
03:46
created

ConsoleFormatter::onEngineStart()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 2

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 0
loc 14
ccs 12
cts 12
cp 1
rs 9.4285
cc 2
eloc 10
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Paraunit\Printer;
4
5
use Paraunit\Lifecycle\EngineEvent;
6
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
7
8
/**
9
 * Class ConsoleFormatter
10
 * @package Paraunit\Printer
11
 */
12
class ConsoleFormatter
13
{
14
    /**
15
     * @param EngineEvent $engineEvent
16
     */
17 14
    public function onEngineStart(EngineEvent $engineEvent)
18
    {
19 14
        $formatter = $engineEvent->getOutputInterface()->getFormatter();
20
21 14
        if ($formatter) {
22 14
            $formatter->setStyle('ok', $this->createNewStyle('green'));
23 14
            $formatter->setStyle('skip', $this->createNewStyle('yellow'));
24 14
            $formatter->setStyle('warning', $this->createNewStyle('yellow'));
25 14
            $formatter->setStyle('incomplete', $this->createNewStyle('blue'));
26 14
            $formatter->setStyle('fail', $this->createNewStyle('red'));
27 14
            $formatter->setStyle('error', $this->createNewStyle('red'));
28 14
            $formatter->setStyle('abnormal', $this->createNewStyle('magenta'));
29 14
        }
30 14
    }
31
32
    /**
33
     * @param string $color
34
     * @return OutputFormatterStyle
35
     */
36 14
    private function createNewStyle($color)
37
    {
38 14
        return new OutputFormatterStyle($color, null, array('bold', 'blink'));
39
    }
40
}
41