Conditions | 6 |
Paths | 6 |
Total Lines | 19 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 6.105 |
Changes | 0 |
1 | <?php |
||
26 | 31 | public static function getColoredString($string, $foreground = NULL, $background = NULL) |
|
27 | { |
||
28 | 31 | if (!self::$enableColors) { |
|
29 | 14 | return $string; |
|
30 | } |
||
31 | 17 | if ($foreground === NULL && $background === NULL) { |
|
32 | 7 | return $string; |
|
33 | } |
||
34 | |||
35 | 15 | $colored = ""; |
|
36 | 15 | if (isset(self::$foregroundColors[$foreground])) { |
|
37 | 15 | $colored .= "\033[" . self::$foregroundColors[$foreground] . "m"; |
|
38 | 15 | } |
|
39 | 15 | if (isset(self::$backgroundColors[$background])) { |
|
40 | $colored .= "\033[" . self::$backgroundColors[$background] . "m"; |
||
41 | } |
||
42 | 15 | $colored .= $string . "\033[0m"; |
|
43 | 15 | return $colored; |
|
44 | } |
||
45 | |||
46 | } |