1 | <?php |
||
27 | abstract class AbstractConfig extends ArrayObject implements ConfigInterface |
||
28 | { |
||
29 | |||
30 | /** |
||
31 | * Array of strings that are used as delimiters to parse configuration keys. |
||
32 | * |
||
33 | * @since 0.1.6 |
||
34 | * |
||
35 | * @var array |
||
36 | */ |
||
37 | protected $delimiter = ['\\', '/', '.']; |
||
38 | |||
39 | /** |
||
40 | * Instantiate the AbstractConfig object. |
||
41 | * |
||
42 | * @since 0.1.0 |
||
43 | * @since 0.1.6 Accepts a delimiter to parse configuration keys. |
||
44 | * |
||
45 | * @param array $config Array with settings. |
||
46 | * @param string[]|string|null $delimiter A string or array of strings that are used as delimiters to parse |
||
47 | * configuration keys. Defaults to "\", "/" & ".". |
||
48 | */ |
||
49 | 2 | public function __construct(array $config, $delimiter = null) |
|
58 | |||
59 | /** |
||
60 | * Get the value of a specific key. |
||
61 | * |
||
62 | * To get a value several levels deep, add the keys for each level as a comma-separated list. |
||
63 | * |
||
64 | * @since 0.1.0 |
||
65 | * @since 0.1.4 Accepts list of keys. |
||
66 | * |
||
67 | * @param string ... List of keys. |
||
68 | * @return mixed |
||
69 | * @throws BadMethodCallException If no argument was provided. |
||
70 | * @throws OutOfRangeException If an unknown key is requested. |
||
71 | */ |
||
72 | 2 | public function getKey() |
|
95 | |||
96 | /** |
||
97 | * Check whether the Config has a specific key. |
||
98 | * |
||
99 | * To check a value several levels deep, add the keys for each level as a comma-separated list. |
||
100 | * |
||
101 | * @since 0.1.0 |
||
102 | * @since 0.1.4 Accepts list of keys. |
||
103 | * |
||
104 | * @param string ... List of keys. |
||
105 | * @return bool |
||
106 | */ |
||
107 | 2 | public function hasKey() |
|
127 | |||
128 | /** |
||
129 | * Get a (multi-dimensional) array of all the configuration settings. |
||
130 | * |
||
131 | * @since 0.1.4 |
||
132 | * |
||
133 | * @return array |
||
134 | */ |
||
135 | 1 | public function getAll() |
|
139 | |||
140 | /** |
||
141 | * Get the an array with all the keys |
||
142 | * |
||
143 | * @since 0.1.0 |
||
144 | * @return array |
||
|
|||
145 | */ |
||
146 | 1 | public function getKeys() |
|
150 | |||
151 | /** |
||
152 | * Recursively extract the configuration key arguments from an arbitrary array. |
||
153 | * |
||
154 | * @since 0.1.6 |
||
155 | * |
||
156 | * @param array $arguments Array as fetched through get_func_args(). |
||
157 | * @return array Array of strings. |
||
158 | * @throws BadMethodCallException If no argument was provided. |
||
159 | */ |
||
160 | 4 | protected function getKeyArguments($arguments) |
|
176 | |||
177 | /** |
||
178 | * Extract individual keys from a delimited string. |
||
179 | * |
||
180 | * @since 0.1.6 |
||
181 | * |
||
182 | * @param string $keyString Delimited string of keys. |
||
183 | * @return array Array of key strings. |
||
184 | */ |
||
185 | 1 | protected function parseKeysString($keyString) |
|
194 | |||
195 | /** |
||
196 | * Validate the Config file. |
||
197 | * |
||
198 | * @since 0.1.0 |
||
199 | * @return boolean |
||
200 | */ |
||
201 | abstract public function isValid(); |
||
202 | } |
||
203 |
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.