Completed
Push — master ( c02786...ba52e0 )
by Alessandro
5s
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 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
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 15
    public function onEngineStart(EngineEvent $engineEvent)
18
    {
19 15
        $formatter = $engineEvent->getOutputInterface()->getFormatter();
20
21 15
        if ($formatter) {
22 15
            $formatter->setStyle('ok', $this->createNewStyle('green'));
23 15
            $formatter->setStyle('skip', $this->createNewStyle('yellow'));
24 15
            $formatter->setStyle('warning', $this->createNewStyle('yellow'));
25 15
            $formatter->setStyle('incomplete', $this->createNewStyle('blue'));
26 15
            $formatter->setStyle('fail', $this->createNewStyle('red'));
27 15
            $formatter->setStyle('error', $this->createNewStyle('red'));
28 15
            $formatter->setStyle('abnormal', $this->createNewStyle('magenta'));
29 15
        }
30 15
    }
31
32
    /**
33
     * @param string $color
34
     * @return OutputFormatterStyle
35
     */
36 15
    private function createNewStyle($color)
37
    {
38 15
        return new OutputFormatterStyle($color, null, array('bold', 'blink'));
39
    }
40
}
41