1 | <?php |
||
18 | final class Konfig extends AbstractKonfig |
||
19 | { |
||
20 | /** |
||
21 | * @var FileParser[] $fileParsers Array of file parsers objects |
||
22 | * @since 0.1 |
||
23 | */ |
||
24 | protected $fileParsers; |
||
25 | |||
26 | /** |
||
27 | * Stores loaded configuration files |
||
28 | * |
||
29 | * @var array $loadedFiles Array of loaded configuration files |
||
30 | * @since 0.1 |
||
31 | */ |
||
32 | protected static $loadedFiles = []; |
||
33 | |||
34 | /** |
||
35 | * Loads a supported configuration file format. |
||
36 | * |
||
37 | * @param string|array|mixed $path String file | configuration array | Konfig instance |
||
38 | * @throws EmptyDirectoryException If `$path` is an empty directory |
||
39 | */ |
||
40 | 33 | public function __construct($path, array $parsers = []) |
|
69 | |||
70 | /** |
||
71 | * Static method for loading a Konfig instance. |
||
72 | * |
||
73 | * @param string|array|mixed $path string file | configuration array | Konfig instance |
||
74 | * @return Konfig |
||
75 | */ |
||
76 | 3 | public static function load($path = null) |
|
80 | |||
81 | /** |
||
82 | * Static method for getting loaded Konfig files. |
||
83 | * |
||
84 | * @return array |
||
85 | */ |
||
86 | public static function loaded() |
||
90 | |||
91 | /** |
||
92 | * Static method for getting all Konfig keys. |
||
93 | * |
||
94 | * @return array |
||
95 | */ |
||
96 | public static function keys() |
||
100 | |||
101 | /** |
||
102 | * @return FileParser[] |
||
103 | * @since 0.1 |
||
104 | */ |
||
105 | public function getFileParsers() |
||
109 | |||
110 | /** |
||
111 | * @return void |
||
112 | * @since 0.1 |
||
113 | */ |
||
114 | protected function addFileParser(FileParser $fileParser) |
||
118 | |||
119 | /** |
||
120 | * @return void |
||
121 | * @since 0.1 |
||
122 | */ |
||
123 | protected function setFileParsers(array $fileParsers = []) |
||
143 | |||
144 | /** |
||
145 | * Gets a parser for a given file extension |
||
146 | * |
||
147 | * @param string $ext |
||
148 | * @return Konfig\FileParser |
||
149 | * @throws UnsupportedFileFormatException If `$path` is an unsupported file format |
||
150 | */ |
||
151 | 27 | private function getParser($ext) |
|
175 | |||
176 | /** |
||
177 | * Gets an array of paths |
||
178 | * |
||
179 | * @param array $path |
||
180 | * @return array |
||
181 | * @throws FileNotFoundException If a file is not found in `$path` |
||
182 | */ |
||
183 | private function pathFromArray($path) |
||
213 | |||
214 | /** |
||
215 | * Checks `$path` to see if it is either an array, a directory, or a file |
||
216 | * |
||
217 | * @param string|array $path |
||
218 | * @return array |
||
219 | * @throws EmptyDirectoryException If `$path` is an empty directory |
||
220 | * @throws FileNotFoundException If a file is not found at `$path` |
||
221 | */ |
||
222 | 30 | private function getValidPath($path = null) |
|
247 | |||
248 | /** |
||
249 | * @return string |
||
250 | * @since 0.1 |
||
251 | */ |
||
252 | public function __toString() |
||
256 | } |
||
257 | |||
259 |