1 | <?php |
||
5 | class Filter |
||
6 | { |
||
7 | protected $arguments = []; |
||
8 | |||
9 | /** |
||
10 | * Set the available arguments |
||
11 | * |
||
12 | * @param array $arguments |
||
13 | */ |
||
14 | 20 | public function setArguments(array $arguments) |
|
18 | |||
19 | /** |
||
20 | * Retrieve optional arguments |
||
21 | * |
||
22 | * @return Argument[] |
||
23 | */ |
||
24 | 4 | public function optional() |
|
28 | |||
29 | /** |
||
30 | * Retrieve required arguments |
||
31 | * |
||
32 | * @return Argument[] |
||
33 | */ |
||
34 | 4 | public function required() |
|
38 | |||
39 | /** |
||
40 | * Retrieve arguments with prefix |
||
41 | * |
||
42 | * @return Argument[] |
||
43 | */ |
||
44 | 20 | public function withPrefix() |
|
48 | |||
49 | /** |
||
50 | * Retrieve arguments without prefix |
||
51 | * |
||
52 | * @return Argument[] |
||
53 | */ |
||
54 | 20 | public function withoutPrefix() |
|
58 | |||
59 | /** |
||
60 | * Find all required arguments that don't have values after parsing. |
||
61 | * |
||
62 | * These arguments weren't defined on the command line. |
||
63 | * |
||
64 | * @return Argument[] |
||
65 | */ |
||
66 | 16 | public function missing() |
|
70 | |||
71 | /** |
||
72 | * Filter defined arguments as to whether they are required or not |
||
73 | * |
||
74 | * @param string[] $filters |
||
75 | * |
||
76 | * @return Argument[] |
||
77 | */ |
||
78 | 20 | protected function filterArguments($filters = []) |
|
92 | |||
93 | /** |
||
94 | * Determine whether an argument as a prefix |
||
95 | * |
||
96 | * @param Argument $argument |
||
97 | * |
||
98 | * @return bool |
||
99 | */ |
||
100 | 20 | protected function noPrefix($argument) |
|
104 | |||
105 | /** |
||
106 | * Determine whether an argument as a prefix |
||
107 | * |
||
108 | * @param Argument $argument |
||
109 | * |
||
110 | * @return bool |
||
111 | */ |
||
112 | 20 | protected function hasPrefix($argument) |
|
116 | |||
117 | /** |
||
118 | * Determine whether an argument is required |
||
119 | * |
||
120 | * @param Argument $argument |
||
121 | * |
||
122 | * @return bool |
||
123 | */ |
||
124 | 20 | protected function isRequired($argument) |
|
128 | |||
129 | /** |
||
130 | * Determine whether an argument is optional |
||
131 | * |
||
132 | * @param Argument $argument |
||
133 | * |
||
134 | * @return bool |
||
135 | */ |
||
136 | 4 | protected function isOptional($argument) |
|
140 | |||
141 | /** |
||
142 | * Determine whether an argument is optional |
||
143 | * |
||
144 | * @param Argument $argument |
||
145 | * |
||
146 | * @return bool |
||
147 | */ |
||
148 | 4 | protected function noValue($argument) |
|
152 | |||
153 | /** |
||
154 | * Compare two arguments by their short and long prefixes. |
||
155 | * |
||
156 | * @see usort() |
||
157 | * |
||
158 | * @param Argument $a |
||
159 | * @param Argument $b |
||
160 | * |
||
161 | * @return int |
||
162 | */ |
||
163 | 16 | public function compareByPrefix(Argument $a, Argument $b) |
|
171 | |||
172 | /** |
||
173 | * Prep the prefix string for comparison |
||
174 | * |
||
175 | * @param Argument $argument |
||
176 | * |
||
177 | * @return string |
||
178 | */ |
||
179 | 16 | protected function prefixCompareString(Argument $argument) |
|
183 | } |
||
184 |