1 | <?php |
||
22 | class BashColor |
||
23 | { |
||
24 | /** |
||
25 | * Options. |
||
26 | * |
||
27 | * @var array |
||
28 | */ |
||
29 | private static $options = array( |
||
30 | 'none' => 0, // reset/remove all option |
||
31 | 'bold' => 1, // bold/bright |
||
32 | 'bright' => 1, // bold/bright |
||
33 | 'dim' => 2, // dim |
||
34 | 'underlined' => 4, // underlined |
||
35 | 'blink' => 5, // blink |
||
36 | 'reverse' => 7, // reverse/invert |
||
37 | 'invert' => 7, // reverse/invert |
||
38 | 'hidden' => 8, // hidden |
||
39 | ); |
||
40 | |||
41 | /** |
||
42 | * Foreground colors. |
||
43 | * |
||
44 | * @var array |
||
45 | */ |
||
46 | private static $foregroundColors = array( |
||
47 | 'default' => 39, // default (usually green, white or light gray) |
||
48 | 'black' => 30, // black |
||
49 | 'red' => 31, // red (don't use with green background) |
||
50 | 'green' => 32, // green |
||
51 | 'yellow' => 33, // yellow |
||
52 | 'blue' => 34, // blue |
||
53 | 'magenta' => 35, // magenta/purple |
||
54 | 'purple' => 35, // magenta/purple |
||
55 | 'cyan' => 36, // cyan |
||
56 | 'light_gray' => 37, // light gray |
||
57 | 'dark_gray' => 90, // dark gray |
||
58 | 'light_red' => 91, // light red |
||
59 | 'light_green' => 92, // light green |
||
60 | 'light_yellow' => 93, // light yellow |
||
61 | 'light_blue' => 94, // light blue |
||
62 | 'light_magenta' => 95, // light magenta/pink |
||
63 | 'light_pink' => 95, // light magenta/pink |
||
64 | 'light_cyan' => 96, // light cyan |
||
65 | 'white' => 97, // white |
||
66 | ); |
||
67 | |||
68 | /** |
||
69 | * Backgound colors. |
||
70 | * |
||
71 | * @var array |
||
72 | */ |
||
73 | private static $backgroundColors = array( |
||
74 | 'default' => 49, // Default background color (usually black or blue) |
||
75 | 'black' => 40, // Black |
||
76 | 'red' => 41, // Red |
||
77 | 'green' => 42, // Green |
||
78 | 'yellow' => 43, // Yellow |
||
79 | 'blue' => 44, // Blue |
||
80 | 'magenta' => 45, // Magenta/Purple |
||
81 | 'purple' => 45, // Magenta/Purple |
||
82 | 'cyan' => 46, // Cyan |
||
83 | 'light_gray' => 47, // Light Gray (don't use with white foreground) |
||
84 | 'dark_gray' => 100, // Dark Gray (don't use with black foreground) |
||
85 | 'light_red' => 101, // Light Red |
||
86 | 'light_green' => 102, // Light Green (don't use with white foreground) |
||
87 | 'light_yellow' => 103, // Light Yellow (don't use with white foreground) |
||
88 | 'light_blue' => 104, // Light Blue (don't use with light yellow foreground) |
||
89 | 'light_magenta' => 105, // Light Magenta/Pink (don't use with light foreground) |
||
90 | 'light_pink' => 105, // Light Magenta/Pink (don't use with light foreground) |
||
91 | 'light_cyan' => 106, // Light Cyan (don't use with white foreground) |
||
92 | 'white' => 107, // White (don't use with light foreground) |
||
93 | ); |
||
94 | |||
95 | /** |
||
96 | * Return colorized string. |
||
97 | * |
||
98 | * @param string $string |
||
99 | * |
||
100 | * @return string |
||
101 | */ |
||
102 | 1 | public static function render($string) |
|
111 | |||
112 | /** |
||
113 | * Parse attributes. |
||
114 | * |
||
115 | * @param string $attributesString |
||
116 | * |
||
117 | * @return array |
||
118 | */ |
||
119 | 1 | public static function parseAttributes($attributesString) |
|
148 | |||
149 | /** |
||
150 | * Snake case. |
||
151 | * |
||
152 | * @param string $string |
||
153 | * |
||
154 | * @return string |
||
155 | */ |
||
156 | public static function snakeCase($string) |
||
162 | |||
163 | /** |
||
164 | * Returns all foreground color names. |
||
165 | * |
||
166 | * @return array |
||
167 | */ |
||
168 | 1 | public static function getForegroundColors() |
|
172 | |||
173 | /** |
||
174 | * Returns all background color names. |
||
175 | * |
||
176 | * @return array |
||
177 | */ |
||
178 | 1 | public static function getBackgroundColors() |
|
182 | } |
||
183 |