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