1 | <?php |
||
87 | class CLImate |
||
88 | { |
||
89 | /** |
||
90 | * An instance of the Style class |
||
91 | * |
||
92 | * @var \League\CLImate\Decorator\Style $style |
||
93 | */ |
||
94 | public $style; |
||
95 | |||
96 | /** |
||
97 | * An instance of the Terminal Object Router class |
||
98 | * |
||
99 | * @var \League\CLImate\TerminalObject\Router\Router $router |
||
100 | */ |
||
101 | protected $router; |
||
102 | |||
103 | /** |
||
104 | * An instance of the Settings Manager class |
||
105 | * |
||
106 | * @var \League\CLImate\Settings\Manager $settings |
||
107 | */ |
||
108 | protected $settings; |
||
109 | |||
110 | /** |
||
111 | * An instance of the Argument Manager class |
||
112 | * |
||
113 | * @var \League\CLImate\Argument\Manager $arguments |
||
114 | */ |
||
115 | public $arguments; |
||
116 | |||
117 | /** |
||
118 | * An instance of the Output class |
||
119 | * |
||
120 | * @var \League\CLImate\Util\Output $output |
||
121 | */ |
||
122 | public $output; |
||
123 | |||
124 | /** |
||
125 | * An instance of the Util Factory |
||
126 | * |
||
127 | * @var \League\CLImate\Util\UtilFactory $util |
||
128 | 948 | */ |
|
129 | protected $util; |
||
130 | 948 | ||
131 | 948 | public function __construct() |
|
140 | |||
141 | /** |
||
142 | * Set the style property |
||
143 | 948 | * |
|
144 | * @param \League\CLImate\Decorator\Style $style |
||
145 | 948 | */ |
|
146 | 948 | public function setStyle(Style $style) |
|
150 | |||
151 | /** |
||
152 | * Set the router property |
||
153 | 948 | * |
|
154 | * @param \League\CLImate\TerminalObject\Router\Router $router |
||
155 | 948 | */ |
|
156 | 948 | public function setRouter(Router $router) |
|
160 | |||
161 | /** |
||
162 | * Set the settings property |
||
163 | 948 | * |
|
164 | * @param \League\CLImate\Settings\Manager $manager |
||
165 | 948 | */ |
|
166 | 948 | public function setSettingsManager(SettingsManager $manager) |
|
170 | |||
171 | /** |
||
172 | * Set the arguments property |
||
173 | 948 | * |
|
174 | * @param \League\CLImate\Argument\Manager $manager |
||
175 | 948 | */ |
|
176 | 948 | public function setArgumentManager(ArgumentManager $manager) |
|
180 | |||
181 | /** |
||
182 | * Set the output property |
||
183 | 948 | * |
|
184 | * @param \League\CLImate\Util\Output $output |
||
185 | 948 | */ |
|
186 | 948 | public function setOutput(Output $output) |
|
190 | |||
191 | /** |
||
192 | * Set the util property |
||
193 | 948 | * |
|
194 | * @param \League\CLImate\Util\UtilFactory $util |
||
195 | 948 | */ |
|
196 | 948 | public function setUtil(UtilFactory $util) |
|
200 | |||
201 | /** |
||
202 | * Extend CLImate with custom methods |
||
203 | * |
||
204 | * @param string|object|array $class |
||
205 | * @param string $key Optional custom key instead of class name |
||
206 | 36 | * |
|
207 | * @return \League\CLImate\CLImate |
||
208 | 36 | */ |
|
209 | public function extend($class, $key = null) |
||
215 | |||
216 | /** |
||
217 | * Force ansi support on |
||
218 | 4 | * |
|
219 | * @return \League\CLImate\CLImate |
||
220 | 4 | */ |
|
221 | public function forceAnsiOn() |
||
227 | |||
228 | /** |
||
229 | * Force ansi support off |
||
230 | 4 | * |
|
231 | * @return \League\CLImate\CLImate |
||
232 | 4 | */ |
|
233 | public function forceAnsiOff() |
||
239 | |||
240 | /** |
||
241 | * Write line to writer once |
||
242 | * |
||
243 | * @param string|array $writer |
||
244 | 4 | * |
|
245 | * @return \League\CLImate\CLImate |
||
246 | 4 | */ |
|
247 | public function to($writer) |
||
253 | |||
254 | /** |
||
255 | * Output the program's usage statement |
||
256 | 4 | * |
|
257 | * @param array $argv |
||
258 | 4 | */ |
|
259 | public function usage(array $argv = null) |
||
263 | |||
264 | /** |
||
265 | * Set the program's description |
||
266 | * |
||
267 | * @param string $description |
||
268 | 4 | * |
|
269 | * @return \League\CLImate\CLImate |
||
270 | 4 | */ |
|
271 | public function description($description) |
||
277 | |||
278 | /** |
||
279 | * Check if we have valid output |
||
280 | * |
||
281 | * @param mixed $output |
||
282 | 76 | * |
|
283 | * @return boolean |
||
284 | 76 | */ |
|
285 | 48 | protected function hasOutput($output) |
|
294 | |||
295 | /** |
||
296 | * Search for the method within the string |
||
297 | * and route it if we find one. |
||
298 | * |
||
299 | * @param string $method |
||
300 | * @param string $name |
||
301 | 568 | * |
|
302 | * @return string The new string without the executed method. |
||
303 | */ |
||
304 | 568 | protected function parseStyleMethod($method, $name) |
|
319 | |||
320 | /** |
||
321 | * Search for any style methods within the name and apply them |
||
322 | * |
||
323 | * @param string $name |
||
324 | * @param array $method_search |
||
325 | 568 | * |
|
326 | * @return string Anything left over after applying styles |
||
327 | */ |
||
328 | 568 | protected function applyStyleMethods($name, $method_search = null) |
|
343 | |||
344 | /** |
||
345 | * Search for style methods in the current name |
||
346 | * |
||
347 | * @param string $name |
||
348 | 568 | * @param array $search |
|
349 | * @return string |
||
350 | */ |
||
351 | 568 | protected function searchForStyleMethods($name, $search) |
|
361 | |||
362 | /** |
||
363 | * Build up the terminal object and return it |
||
364 | * |
||
365 | * @param string $name |
||
366 | * @param array $arguments |
||
367 | 568 | * |
|
368 | * @return object|null |
||
369 | */ |
||
370 | 568 | protected function buildTerminalObject($name, $arguments) |
|
386 | |||
387 | /** |
||
388 | * Route anything leftover after styles were applied |
||
389 | * |
||
390 | * @param string $name |
||
391 | * @param array $arguments |
||
392 | 568 | * |
|
393 | * @return object|null |
||
394 | */ |
||
395 | 568 | protected function routeRemainingMethod($name, array $arguments) |
|
413 | |||
414 | /** |
||
415 | * Magic method for anything called that doesn't exist |
||
416 | * |
||
417 | * @param string $requested_method |
||
418 | * @param array $arguments |
||
419 | * |
||
420 | * @return \League\CLImate\CLImate|\League\CLImate\TerminalObject\Dynamic\DynamicTerminalObject |
||
421 | * |
||
422 | 568 | * List of many of the possible method being called here |
|
423 | * documented at the top of this class. |
||
424 | */ |
||
425 | 568 | public function __call($requested_method, $arguments) |
|
445 | } |
||
446 |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.