1 | <?php |
||
36 | final class Konfig extends AbstractKonfig |
||
37 | { |
||
38 | /** |
||
39 | * Array of file parsers objects. |
||
40 | * |
||
41 | * @var array|null |
||
42 | * |
||
43 | * @since 0.1.0 |
||
44 | */ |
||
45 | protected $fileParsers; |
||
46 | |||
47 | /** |
||
48 | * Stores loaded configuration files. |
||
49 | * |
||
50 | * @var array Array of loaded configuration files |
||
51 | * |
||
52 | * @since 0.1.0 |
||
53 | */ |
||
54 | protected static $loadedFiles = []; |
||
55 | |||
56 | /** |
||
57 | * Array of loaded data. |
||
58 | * |
||
59 | * @var array|null |
||
60 | * |
||
61 | * @since 0.1.0 |
||
62 | */ |
||
63 | protected static $loadedData = null; |
||
64 | |||
65 | /** |
||
66 | * Loads a supported configuration file format. |
||
67 | * |
||
68 | * @param string|array|mixed $path String file |
||
69 | * | configuration array | Konfig instance |
||
70 | * @param array $parsers Parsers |
||
71 | * |
||
72 | * @throws EmptyDirectoryException If `$path` is an empty directory |
||
73 | */ |
||
74 | 33 | public function __construct($path = null, array $parsers = []) |
|
108 | |||
109 | /** |
||
110 | * Static method for loading a Konfig instance. |
||
111 | * |
||
112 | * @param string|array|mixed $path string file | configuration array |
||
113 | * | Konfig instance |
||
114 | * @param array $parsers Parsers to use with Konfig |
||
115 | * @param bool $overwrite Whether to overwrite existing values |
||
116 | * @param bool $cache Allow caching |
||
117 | * |
||
118 | * @return Konfig |
||
119 | */ |
||
120 | 3 | public static function load( |
|
128 | |||
129 | /** |
||
130 | * Static method for getting loaded Konfig files. |
||
131 | * |
||
132 | * @return array |
||
133 | */ |
||
134 | public static function loaded() |
||
138 | |||
139 | /** |
||
140 | * Get file parsers. |
||
141 | * |
||
142 | * @return FileParser[] |
||
143 | * |
||
144 | * @since 0.1.0 |
||
145 | * @codeCoverageIgnore |
||
146 | */ |
||
147 | public function getFileParsers() |
||
151 | |||
152 | /** |
||
153 | * Add file parsers. |
||
154 | * |
||
155 | * @param FileParser $fileParser Parser |
||
156 | * |
||
157 | * @return void Void |
||
158 | * @since 0.1.0 |
||
159 | * @codeCoverageIgnore |
||
160 | */ |
||
161 | protected function addFileParser(FileParser $fileParser) |
||
165 | |||
166 | /** |
||
167 | * Set file parsers. |
||
168 | * |
||
169 | * @param array $fileParsers Parsers array |
||
170 | * |
||
171 | * @return void Void |
||
172 | * @since 0.1.0 |
||
173 | * @codeCoverageIgnore |
||
174 | */ |
||
175 | protected function setFileParsers(array $fileParsers = []) |
||
196 | |||
197 | /** |
||
198 | * Gets a parser for a given file extension. |
||
199 | * |
||
200 | * @param string $ext File extension |
||
201 | * |
||
202 | * @return FileParser |
||
203 | * |
||
204 | * @throws Exception If `$ext` is empty |
||
205 | * @throws UnsupportedFileFormatException If `$path` |
||
206 | * is an unsupported file format |
||
207 | * @codeCoverageIgnore |
||
208 | */ |
||
209 | private function getParser($ext = null) |
||
235 | |||
236 | /** |
||
237 | * Gets an array of paths. |
||
238 | * |
||
239 | * @param array $path Path to analyze and handle |
||
240 | * |
||
241 | * @return array |
||
242 | * |
||
243 | * @throws FileNotFoundException If a file is not found in `$path` |
||
244 | */ |
||
245 | private function pathFromArray($path) |
||
279 | |||
280 | /** |
||
281 | * Checks `$path` to see if it is either an array, a directory, or a file. |
||
282 | * |
||
283 | * @param string|array $path Path to analyze and handle |
||
284 | * |
||
285 | * @return array |
||
286 | * |
||
287 | * @throws EmptyDirectoryException If `$path` is an empty directory |
||
288 | * @throws FileNotFoundException If a file is not found at `$path` |
||
289 | */ |
||
290 | 30 | private function getValidPath($path) |
|
319 | |||
320 | /** |
||
321 | * __call. |
||
322 | * |
||
323 | * @param string $name Method name |
||
324 | * @param string|array $arguments Arguments to pass |
||
325 | * |
||
326 | * @return mixed |
||
327 | * @since 0.2.5 |
||
328 | * @codeCoverageIgnore |
||
329 | */ |
||
330 | public function __call($name, $arguments) |
||
340 | |||
341 | /** |
||
342 | * __callStatic. |
||
343 | * |
||
344 | * @param string $name Method name |
||
345 | * @param string|array $arguments Arguments to pass |
||
346 | * |
||
347 | * @return mixed |
||
348 | * @since 0.2.5 |
||
349 | * @codeCoverageIgnore |
||
350 | */ |
||
351 | public static function __callStatic($name, $arguments) |
||
361 | |||
362 | /** |
||
363 | * __toString. |
||
364 | * |
||
365 | * @return string |
||
366 | * @since 0.1.2 |
||
367 | * @codeCoverageIgnore |
||
368 | */ |
||
369 | public function __toString() |
||
373 | } |
||
374 | |||
376 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.