1 | <?php |
||
19 | class Config extends AbstractConfig |
||
20 | { |
||
21 | /** |
||
22 | * All file formats supported by Config |
||
23 | * |
||
24 | * @var array |
||
25 | */ |
||
26 | private $supportedFileParsers = array( |
||
27 | 'Noodlehaus\FileParser\Php', |
||
28 | 'Noodlehaus\FileParser\Ini', |
||
29 | 'Noodlehaus\FileParser\Json', |
||
30 | 'Noodlehaus\FileParser\Xml', |
||
31 | 'Noodlehaus\FileParser\Yaml' |
||
32 | ); |
||
33 | |||
34 | /** |
||
35 | * Static method for loading a Config instance. |
||
36 | * |
||
37 | * @param string|array $path |
||
38 | * @param boolean $prefix |
||
39 | * |
||
40 | 3 | * @return Config |
|
41 | */ |
||
42 | 3 | public static function load($path, $prefix = false) |
|
46 | |||
47 | /** |
||
48 | * Loads a supported configuration file format. |
||
49 | * |
||
50 | * @param string|array $path |
||
51 | * @param boolean $prefix |
||
52 | 33 | * |
|
53 | * @throws EmptyDirectoryException If `$path` is an empty directory |
||
54 | 33 | */ |
|
55 | 24 | public function __construct($path, $prefix = false) |
|
81 | |||
82 | /** |
||
83 | * Gets a parser for a given file extension |
||
84 | 27 | * |
|
85 | * @param string $extension |
||
86 | 27 | * |
|
87 | 27 | * @return FileParserInterface |
|
88 | 23 | * |
|
89 | * @throws UnsupportedFormatException If `$path` is an unsupported file format |
||
90 | */ |
||
91 | 18 | private function getParser($extension) |
|
103 | |||
104 | /** |
||
105 | * Gets an array of paths |
||
106 | 12 | * |
|
107 | * @param array $path |
||
108 | 12 | * |
|
109 | * @return array |
||
110 | 12 | * |
|
111 | * @throws FileNotFoundException If a file is not found at `$path` |
||
112 | */ |
||
113 | private function getPathFromArray($path) |
||
141 | |||
142 | /** |
||
143 | * Checks `$path` to see if it is either an array, a directory, or a file |
||
144 | * |
||
145 | * @param string|array $path |
||
146 | 30 | * |
|
147 | * @return array |
||
148 | * |
||
149 | 30 | * @throws EmptyDirectoryException If `$path` is an empty directory |
|
150 | 12 | * |
|
151 | * @throws FileNotFoundException If a file is not found at `$path` |
||
152 | */ |
||
153 | private function getValidPath($path) |
||
175 | } |
||
176 |