1 | <?php |
||
26 | abstract class AbstractConfig extends ArrayObject implements ConfigInterface |
||
27 | { |
||
28 | |||
29 | /** |
||
30 | * Array of strings that are used as delimiters to parse configuration keys. |
||
31 | * |
||
32 | * @since 0.1.6 |
||
33 | * |
||
34 | * @var array |
||
35 | */ |
||
36 | protected $delimiter = ['\\', '/', '.']; |
||
37 | |||
38 | /** |
||
39 | * Instantiate the AbstractConfig object. |
||
40 | * |
||
41 | * @since 0.1.0 |
||
42 | * @since 0.1.6 Accepts a delimiter to parse configuration keys. |
||
43 | * |
||
44 | * @param array $config Array with settings. |
||
45 | * @param string[]|string|null $delimiter A string or array of strings that are used as delimiters to parse |
||
46 | * configuration keys. Defaults to "\", "/" & ".". |
||
47 | */ |
||
48 | 3 | public function __construct(array $config, $delimiter = null) |
|
57 | |||
58 | /** |
||
59 | * Get the value of a specific key. |
||
60 | * |
||
61 | * To get a value several levels deep, add the keys for each level as a comma-separated list. |
||
62 | * |
||
63 | * @since 0.1.0 |
||
64 | * @since 0.1.4 Accepts list of keys. |
||
65 | * |
||
66 | * @param string|array $_ List of keys. |
||
67 | * |
||
68 | * @return mixed |
||
69 | * @throws KeyNotFoundException If an unknown key is requested. |
||
70 | */ |
||
71 | 3 | public function getKey($_) |
|
84 | |||
85 | /** |
||
86 | * Check whether the Config has a specific key. |
||
87 | * |
||
88 | * To check a value several levels deep, add the keys for each level as a comma-separated list. |
||
89 | * |
||
90 | * @since 0.1.0 |
||
91 | * @since 0.1.4 Accepts list of keys. |
||
92 | * |
||
93 | * @param string|array $_ List of keys. |
||
94 | * |
||
95 | * @return bool |
||
96 | */ |
||
97 | 3 | public function hasKey($_) |
|
116 | |||
117 | /** |
||
118 | * Get a (multi-dimensional) array of all the configuration settings. |
||
119 | * |
||
120 | * @since 0.1.4 |
||
121 | * |
||
122 | * @return array |
||
123 | */ |
||
124 | 1 | public function getAll() |
|
128 | |||
129 | /** |
||
130 | * Get the an array with all the keys |
||
131 | * |
||
132 | * @since 0.1.0 |
||
133 | * @return array |
||
|
|||
134 | */ |
||
135 | 1 | public function getKeys() |
|
139 | |||
140 | /** |
||
141 | * Get a new config at a specific sub-level. |
||
142 | * |
||
143 | * @since 0.1.13 |
||
144 | * |
||
145 | * @param string|array $_ List of keys. |
||
146 | * |
||
147 | * @return ConfigInterface |
||
148 | * @throws KeyNotFoundException If an unknown key is requested. |
||
149 | */ |
||
150 | 1 | public function getSubConfig($_) |
|
159 | |||
160 | /** |
||
161 | * Validate a set of keys to make sure they exist. |
||
162 | * |
||
163 | * @since 0.1.13 |
||
164 | * |
||
165 | * @param string|array $_ List of keys. |
||
166 | * |
||
167 | * @return array List of keys. |
||
168 | * @throws KeyNotFoundException If an unknown key is requested. |
||
169 | */ |
||
170 | 1 | public function validateKeys($_) |
|
185 | |||
186 | /** |
||
187 | * Reduce the currently stored config array to a subarray at a specific level. |
||
188 | * |
||
189 | * @since 0.1.13 |
||
190 | * |
||
191 | * @param array $keys Array of keys that point to a key down in the hierarchy. |
||
192 | */ |
||
193 | 1 | protected function reduceToSubKey(array $keys) |
|
197 | |||
198 | /** |
||
199 | * Recursively extract the configuration key arguments from an arbitrary array. |
||
200 | * |
||
201 | * @since 0.1.6 |
||
202 | * |
||
203 | * @param array $arguments Array as fetched through get_func_args(). |
||
204 | * |
||
205 | * @return array Array of strings. |
||
206 | */ |
||
207 | 4 | protected function getKeyArguments($arguments) |
|
221 | |||
222 | /** |
||
223 | * Extract individual keys from a delimited string. |
||
224 | * |
||
225 | * @since 0.1.6 |
||
226 | * |
||
227 | * @param string $keyString Delimited string of keys. |
||
228 | * |
||
229 | * @return array Array of key strings. |
||
230 | */ |
||
231 | 2 | protected function parseKeysString($keyString) |
|
238 | |||
239 | /** |
||
240 | * Validate the Config file. |
||
241 | * |
||
242 | * @since 0.1.0 |
||
243 | * @return boolean |
||
244 | */ |
||
245 | abstract public function isValid(); |
||
246 | } |
||
247 |
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.