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

StyleConverter   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 86.67%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 7
c 3
b 0
f 1
lcom 0
cbo 2
dl 0
loc 40
ccs 13
cts 15
cp 0.8667
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
B convert() 0 26 6
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