Conditions | 2 |
Paths | 1 |
Total Lines | 23 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
40 | public static function coloredString(string $string, $color) |
||
41 | { |
||
42 | $availableColors = [ |
||
43 | 'black' => '0;30', |
||
44 | 'dark_gray' => '1;30', |
||
45 | 'blue' => '0;34', |
||
46 | 'light_blue' => '1;34', |
||
47 | 'green' => '0;32', |
||
48 | 'light_green' => '1;32', |
||
49 | 'cyan' => '0;36', |
||
50 | 'light_cyan' => '1;36', |
||
51 | 'red' => '0;31', |
||
52 | 'light_red' => '1;31', |
||
53 | 'purple' => '0;35', |
||
54 | 'light_purple' => '1;35', |
||
55 | 'brown' => '0;33', |
||
56 | 'yellow' => '1;33', |
||
57 | 'light_gray' => '0;37', |
||
58 | 'white' => '1;37' |
||
59 | ]; |
||
60 | $shellColor = $availableColors[$color] ?: $availableColors['white']; |
||
61 | |||
62 | return sprintf("\033[%sm%s\033[0m", $shellColor, $string); |
||
63 | } |
||
65 |