Passed
Push — master ( 1d8e46...0e8320 )
by Théo
02:15
created

configureMutationScoreStyle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 13
rs 9.9666
1
<?php
2
/**
3
 * This code is licensed under the BSD 3-Clause License.
4
 *
5
 * Copyright (c) 2017, Maks Rafalko
6
 * All rights reserved.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions are met:
10
 *
11
 * * Redistributions of source code must retain the above copyright notice, this
12
 *   list of conditions and the following disclaimer.
13
 *
14
 * * Redistributions in binary form must reproduce the above copyright notice,
15
 *   this list of conditions and the following disclaimer in the documentation
16
 *   and/or other materials provided with the distribution.
17
 *
18
 * * Neither the name of the copyright holder nor the names of its
19
 *   contributors may be used to endorse or promote products derived from
20
 *   this software without specific prior written permission.
21
 *
22
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
 */
33
34
declare(strict_types=1);
35
36
namespace Infection\Console;
37
38
use Infection\CannotBeInstantiated;
39
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
40
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
41
use Symfony\Component\Console\Output\OutputInterface;
42
43
/**
44
 * @internal
45
 */
46
final class OutputFormatterStyleConfigurator
47
{
48
    use CannotBeInstantiated;
49
50
    public static function configure(OutputInterface $output): void
51
    {
52
        $formatter = $output->getFormatter();
53
54
        self::configureMutantStyle($formatter);
55
        self::configureDiffStyle($formatter);
56
        self::configureMutationScoreStyle($formatter);
57
    }
58
59
    private static function configureMutantStyle(OutputFormatterInterface $formatter): void
60
    {
61
        $formatter->setStyle('with-error', new OutputFormatterStyle('green'));
62
        $formatter->setStyle(
63
            'uncovered',
64
            new OutputFormatterStyle('blue', null, ['bold'])
65
        );
66
        $formatter->setStyle('timeout', new OutputFormatterStyle('yellow'));
67
        $formatter->setStyle(
68
            'escaped',
69
            new OutputFormatterStyle('red', null, ['bold'])
70
        );
71
        $formatter->setStyle('killed', new OutputFormatterStyle('green'));
72
        $formatter->setStyle('code', new OutputFormatterStyle('white'));
73
    }
74
75
    private static function configureDiffStyle(OutputFormatterInterface $formatter): void
76
    {
77
        $formatter->setStyle('diff-add', new OutputFormatterStyle('green'));
78
        $formatter->setStyle('diff-del', new OutputFormatterStyle('red'));
79
    }
80
81
    private static function configureMutationScoreStyle(OutputFormatterInterface $formatter): void
82
    {
83
        $formatter->setStyle(
84
            'low',
85
            new OutputFormatterStyle('red', null, ['bold'])
86
        );
87
        $formatter->setStyle(
88
            'medium',
89
            new OutputFormatterStyle('yellow', null, ['bold'])
90
        );
91
        $formatter->setStyle(
92
            'high',
93
            new OutputFormatterStyle('green', null, ['bold'])
94
        );
95
    }
96
}
97