1 | <?php |
||
11 | class Manager |
||
12 | { |
||
13 | /** |
||
14 | * An array of arguments passed to the program. |
||
15 | * |
||
16 | * @var array $arguments |
||
17 | */ |
||
18 | protected $arguments = []; |
||
19 | |||
20 | /** |
||
21 | * An array containing the parsed values. |
||
22 | * |
||
23 | * @var array $values ; |
||
24 | */ |
||
25 | protected $values = []; |
||
26 | |||
27 | /** |
||
28 | * An array that contains all the default values |
||
29 | * that are passed to the manager. |
||
30 | * |
||
31 | * @var array |
||
32 | */ |
||
33 | protected $defaultvalues = []; |
||
34 | |||
35 | /** |
||
36 | * @var \Redbox\Cli\Arguments\Parser |
||
37 | */ |
||
38 | protected $parser; |
||
39 | |||
40 | /** |
||
41 | * @var \Redbox\Cli\Arguments\Filter |
||
42 | */ |
||
43 | protected $filter; |
||
44 | |||
45 | /** |
||
46 | * Manager constructor. |
||
47 | */ |
||
48 | 13 | public function __construct() |
|
53 | |||
54 | /** |
||
55 | * Prints out the usage message to the user. |
||
56 | * |
||
57 | * @return void |
||
58 | */ |
||
59 | 2 | public function usage() |
|
100 | |||
101 | /** |
||
102 | * Determine if a given argument has a default value or not. |
||
103 | * One thing to note is that if having no info about the argument |
||
104 | * (being a key in xx is not set) we will return false as well. |
||
105 | * |
||
106 | * @param $argument |
||
107 | * |
||
108 | * @return boolean |
||
109 | */ |
||
110 | 5 | public function hasDefaultValue($argument) |
|
117 | |||
118 | /** |
||
119 | * Set if a argument has defaulted to the default argument or not. |
||
120 | * |
||
121 | * @param string $argument |
||
122 | * @param bool $default |
||
123 | */ |
||
124 | 5 | public function setHasDefaultValue($argument = "", $default = false) |
|
128 | |||
129 | /** |
||
130 | * Get the default value for a argument. |
||
131 | * |
||
132 | * @param string $argument - The argument key |
||
133 | * |
||
134 | * @return false|mixed |
||
135 | */ |
||
136 | 2 | public function getDefaultValue($argument) |
|
144 | |||
145 | /** |
||
146 | * Check to see if a argument is used. |
||
147 | * |
||
148 | * @param string $argument - The name of the argument. |
||
149 | * |
||
150 | * @return bool |
||
151 | */ |
||
152 | 2 | public function has($argument) |
|
156 | |||
157 | /** |
||
158 | * Set a parsed argument. |
||
159 | * |
||
160 | * @param $argument |
||
161 | * @param $value |
||
162 | */ |
||
163 | 10 | public function set($argument, $value) |
|
167 | |||
168 | /** |
||
169 | * Return any set argument or false if the argument is unknown. |
||
170 | * |
||
171 | * @param $argument |
||
172 | * |
||
173 | * @return bool |
||
174 | */ |
||
175 | 5 | public function get($argument) |
|
182 | |||
183 | /** |
||
184 | * Return all given arguments. |
||
185 | * |
||
186 | * @return array |
||
187 | */ |
||
188 | 9 | public function all() |
|
192 | |||
193 | /** |
||
194 | * Add arguments to the list, this could be one or an array of arguments. |
||
195 | * |
||
196 | * @param $argument |
||
197 | * @param array $options |
||
198 | * |
||
199 | * @throws \Exception |
||
200 | */ |
||
201 | 9 | public function add($argument, $options = []) |
|
213 | |||
214 | /** |
||
215 | * This function will be called if we can add an array of commandline arguments |
||
216 | * to parse. |
||
217 | * |
||
218 | * @param array $arguments |
||
219 | * |
||
220 | * @throws \Exception |
||
221 | */ |
||
222 | 9 | protected function addMany(array $arguments = []) |
|
228 | |||
229 | /** |
||
230 | * Go ahead and parse the arguments given. |
||
231 | * |
||
232 | * @throws \Exception |
||
233 | */ |
||
234 | 9 | public function parse() |
|
239 | } |