Completed
Pull Request — master (#34)
by Alessandro
03:03 queued 40s
created

ConsoleFormatter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 3
c 3
b 1
f 0
lcom 0
cbo 4
dl 0
loc 29
ccs 14
cts 14
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A onEngineStart() 0 14 2
A createNewStyle() 0 4 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