1 | <?php |
||
14 | class Style |
||
15 | { |
||
16 | /** |
||
17 | * An array of Decorator objects |
||
18 | * |
||
19 | * @var Component\DecoratorInterface[] $style |
||
20 | */ |
||
21 | protected $style = []; |
||
22 | |||
23 | /** |
||
24 | * An array of the available Decorators |
||
25 | * and their corresponding class names |
||
26 | * |
||
27 | * @var array $available |
||
28 | */ |
||
29 | protected $available = [ |
||
30 | 'format' => 'Format', |
||
31 | 'color' => 'Color', |
||
32 | 'background' => 'BackgroundColor', |
||
33 | 'command' => 'Command', |
||
34 | ]; |
||
35 | |||
36 | protected $parser; |
||
37 | |||
38 | /** |
||
39 | * An array of the current styles applied |
||
40 | * |
||
41 | * @var array $current |
||
42 | */ |
||
43 | protected $current = []; |
||
44 | |||
45 | 948 | public function __construct() |
|
52 | |||
53 | /** |
||
54 | * Get all of the styles available |
||
55 | * |
||
56 | * @return array |
||
57 | */ |
||
58 | 576 | public function all() |
|
68 | |||
69 | /** |
||
70 | * Attempt to get the corresponding code for the style |
||
71 | * |
||
72 | * @param mixed $key |
||
73 | * |
||
74 | * @return mixed |
||
75 | */ |
||
76 | 576 | public function get($key) |
|
86 | |||
87 | /** |
||
88 | * Attempt to set some aspect of the styling, |
||
89 | * return true if attempt was successful |
||
90 | * |
||
91 | * @param string $key |
||
92 | * |
||
93 | * @return boolean |
||
94 | */ |
||
95 | 112 | public function set($key) |
|
105 | |||
106 | /** |
||
107 | * Reset the current styles applied |
||
108 | * |
||
109 | */ |
||
110 | 568 | public function reset() |
|
116 | |||
117 | /** |
||
118 | * Get a new instance of the Parser class based on the current settings |
||
119 | * |
||
120 | * @param \League\CLImate\Util\System\System $system |
||
121 | * |
||
122 | * @return \League\CLImate\Decorator\Parser\Parser |
||
123 | */ |
||
124 | 568 | public function parser(System $system) |
|
128 | |||
129 | /** |
||
130 | * Compile an array of the current codes |
||
131 | * |
||
132 | * @return array |
||
133 | */ |
||
134 | 576 | public function current() |
|
146 | |||
147 | /** |
||
148 | * Make sure that the code is an integer, if not let's try and get it there |
||
149 | * |
||
150 | * @param mixed $code |
||
151 | * |
||
152 | * @return boolean |
||
153 | */ |
||
154 | 112 | protected function validateCode($code) |
|
171 | |||
172 | /** |
||
173 | * Validate an array of codes |
||
174 | * |
||
175 | * @param array $codes |
||
176 | * |
||
177 | * @return boolean |
||
178 | */ |
||
179 | 4 | protected function validateCodeArray(array $codes) |
|
191 | |||
192 | /** |
||
193 | * Convert the array of codes to integers |
||
194 | * |
||
195 | * @param array $codes |
||
196 | * @return array |
||
197 | */ |
||
198 | 576 | protected function convertToCodes(array $codes) |
|
210 | |||
211 | /** |
||
212 | * Retrieve the integers from the mixed code input |
||
213 | * |
||
214 | * @param string|array $code |
||
215 | * |
||
216 | * @return integer|array |
||
217 | */ |
||
218 | 576 | protected function getCode($code) |
|
226 | |||
227 | /** |
||
228 | * Retrieve an array of integers from the array of codes |
||
229 | * |
||
230 | * @param array $codes |
||
231 | * |
||
232 | * @return array |
||
233 | */ |
||
234 | 8 | protected function getCodeArray(array $codes) |
|
242 | |||
243 | /** |
||
244 | * Parse the add method for the style they are trying to add |
||
245 | * |
||
246 | * @param string $method |
||
247 | * |
||
248 | * @return string |
||
249 | */ |
||
250 | 28 | protected function parseAddMethod($method) |
|
254 | |||
255 | /** |
||
256 | * Add a custom style |
||
257 | * |
||
258 | * @param string $style |
||
259 | * @param string $key |
||
260 | * @param string $value |
||
261 | */ |
||
262 | 28 | protected function add($style, $key, $value) |
|
272 | |||
273 | /** |
||
274 | * Magic Methods |
||
275 | * |
||
276 | * List of possible magic methods are at the top of this class |
||
277 | * |
||
278 | * @param string $requested_method |
||
279 | * @param array $arguments |
||
280 | */ |
||
281 | 28 | public function __call($requested_method, $arguments) |
|
295 | } |
||
296 |