Completed
Push — master ( bd5ff6...90c2c7 )
by Bernhard
07:04
created

StyleConverter::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 1
nc 1
nop 0
crap 2
1
<?php
2
3
/*
4
 * This file is part of the webmozart/console package.
5
 *
6
 * (c) Bernhard Schussek <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Webmozart\Console\Adapter;
13
14
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
15
use Webmozart\Console\Api\Formatter\Style;
16
17
/**
18
 * Converts {@link Style} instances to Symfony's {@link OutputFormatterStyle}.
19
 *
20
 * @since  1.0
21
 *
22
 * @author Bernhard Schussek <[email protected]>
23
 */
24
class StyleConverter
0 ignored issues
show
Coding Style introduced by
Since you have declared the constructor as private, maybe you should also declare the class as final.
Loading history...
25
{
26
    /**
27
     * Converts a {@link Style} instance to an {@link OutputFormatterStyle}.
28
     *
29
     * @param Style $style The style to convert.
30
     *
31
     * @return OutputFormatterStyle The converted style.
32
     */
33 258
    public static function convert(Style $style)
34
    {
35 258
        $options = array();
36
37 258
        if ($style->isBold()) {
38 236
            $options[] = 'bold';
39
        }
40
41 258
        if ($style->isBlinking()) {
42 1
            $options[] = 'blink';
43
        }
44
45 258
        if ($style->isUnderlined()) {
46 230
            $options[] = 'underscore';
47
        }
48
49 258
        if ($style->isInverse()) {
50 1
            $options[] = 'reverse';
51
        }
52
53 258
        if ($style->isHidden()) {
54 2
            $options[] = 'conceal';
55
        }
56
57 258
        return new OutputFormatterStyle($style->getForegroundColor(), $style->getBackgroundColor(), $options);
58
    }
59
60
    private function __construct()
61
    {
62
    }
63
}
64