GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

CoverFishColor   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 132
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 9
lcom 1
cbo 0
dl 0
loc 132
rs 10
c 2
b 0
f 1

8 Methods

Rating   Name   Duplication   Size   Complexity  
A setColor() 0 9 2
A tplWhiteColor() 0 4 1
A tplRedColor() 0 4 1
A tplGreenColor() 0 4 1
A tplDarkGrayColor() 0 4 1
A tplYellowColor() 0 4 1
A tplNormalColor() 0 4 1
A tplMarkFailure() 0 4 1
1
<?php
2
3
namespace DF\PHPCoverFish\Common;
4
5
/**
6
 * Class CoverFishColor, color definition for cli output, based on the work on of "\Bart\EscapeColors Benjamin VanEvery"
7
 *
8
 * @package   DF\PHPCoverFish
9
 * @author    Patrick Paechnatz <[email protected]>
10
 * @copyright 2015 Patrick Paechnatz <[email protected]>
11
 * @license   http://www.opensource.org/licenses/MIT
12
 * @link      http://github.com/dunkelfrosch/phpcoverfish/tree
13
 * @since     class available since Release 0.9.0
14
 * @version   0.9.6
15
 *
16
 * @codeCoverageIgnore
17
 */
18
final class CoverFishColor
19
{
20
    /**
21
     * @var array
22
     */
23
    private static $colorTable = array(
24
        'gray' => '0;0',
25
        'black' => '0;30',
26
        'dark_gray' => '1;30',
27
        'red' => '0;31',
28
        'bold_red' => '1;31',
29
        'green' => '0;32',
30
        'bold_green' => '1;32',
31
        'brown' => '0;33',
32
        'yellow' => '1;33',
33
        'blue' => '0;34',
34
        'bold_blue' => '1;34',
35
        'purple' => '0;35',
36
        'bold_purple' => '1;35',
37
        'cyan' => '0;36',
38
        'bold_cyan' => '1;36',
39
        'white' => '1;37',
40
        'bold_gray' => '0;37',
41
        'bg_black' => '40',
42
        'bg_red' => '41',
43
        'bg_magenta' => '45',
44
        'bg_yellow' => '43',
45
        'bg_green' => '42',
46
        'bg_blue' => '44',
47
        'bg_cyan' => '46',
48
        'bg_light_gray' => '47',
49
        'bg_red_fg_yellow' => '33;41',
50
        'bg_red_fg_white' => '37;41',
51
        'bg_yellow_fg_black' => '30;43',
52
    );
53
54
    /**
55
     * Make string appear in color
56
     *
57
     * @param string $color
58
     * @param string $string
59
     *
60
     * @return string
61
     * @throws \Exception
62
     */
63
    public static function setColor($color, $string)
64
    {
65
        if (!isset(self::$colorTable[$color]))
66
        {
67
            throw new \Exception('ansi color is not defined');
68
        }
69
70
        return sprintf("\033[%sm%s\033[0m", self::$colorTable[$color], $string);
71
    }
72
73
    /**
74
     * @param string $content
75
     *
76
     * @return string
77
     * @throws \Exception
78
     */
79
    public static function tplWhiteColor($content)
80
    {
81
        return self::setColor('white', $content);
82
    }
83
84
    /**
85
     * @param string $content
86
     *
87
     * @return string
88
     * @throws \Exception
89
     */
90
    public static function tplRedColor($content)
91
    {
92
        return self::setColor('red', $content);
93
    }
94
95
    /**
96
     * @param string $content
97
     *
98
     * @return string
99
     * @throws \Exception
100
     */
101
    public static function tplGreenColor($content)
102
    {
103
        return self::setColor('green', $content);
104
    }
105
106
    /**
107
     * @param string $content
108
     *
109
     * @return string
110
     * @throws \Exception
111
     */
112
    public static function tplDarkGrayColor($content)
113
    {
114
        return self::setColor('dark_gray', $content);
115
    }
116
117
    /**
118
     * @param string $content
119
     *
120
     * @return string
121
     * @throws \Exception
122
     */
123
    public static function tplYellowColor($content)
124
    {
125
        return self::setColor('yellow', $content);
126
    }
127
128
    /**
129
     * @param string $content
130
     *
131
     * @return string
132
     * @throws \Exception
133
     */
134
    public static function tplNormalColor($content)
135
    {
136
        return self::setColor('gray', $content);
137
    }
138
139
    /**
140
     * @param string $content
141
     *
142
     * @return string
143
     * @throws \Exception
144
     */
145
    public static function tplMarkFailure($content)
146
    {
147
        return self::setColor('yellow', self::setColor('red', $content));
148
    }
149
}