1 | <?php |
||
18 | class Config extends AbstractConfig |
||
19 | { |
||
20 | /** |
||
21 | * All file formats supported by Config |
||
22 | * |
||
23 | * @var array |
||
24 | */ |
||
25 | private $supportedFileParsers = array( |
||
26 | 'Noodlehaus\FileParser\Php', |
||
27 | 'Noodlehaus\FileParser\Ini', |
||
28 | 'Noodlehaus\FileParser\Json', |
||
29 | 'Noodlehaus\FileParser\Xml', |
||
30 | 'Noodlehaus\FileParser\Yaml' |
||
31 | ); |
||
32 | |||
33 | /** |
||
34 | * Static method for loading a Config instance. |
||
35 | * |
||
36 | * @param string|array $path |
||
37 | * |
||
38 | * @return Config |
||
39 | */ |
||
40 | 2 | public static function load($path) |
|
44 | |||
45 | /** |
||
46 | * Loads a supported configuration file format. |
||
47 | * |
||
48 | * @param string|array $path |
||
49 | * |
||
50 | * @throws EmptyDirectoryException If `$path` is an empty directory |
||
51 | */ |
||
52 | 22 | public function __construct($path) |
|
74 | |||
75 | /** |
||
76 | * Gets a parser for a given file extension |
||
77 | * |
||
78 | * @param string $extension |
||
79 | * |
||
80 | * @return Noodlehaus\FileParser\FileParserInterface |
||
81 | * |
||
82 | * @throws UnsupportedFormatException If `$path` is an unsupported file format |
||
83 | */ |
||
84 | 18 | private function getParser($extension) |
|
96 | |||
97 | /** |
||
98 | * Gets an array of paths |
||
99 | * |
||
100 | * @param array $path |
||
101 | * |
||
102 | * @return array |
||
103 | * |
||
104 | * @throws FileNotFoundException If a file is not found at `$path` |
||
105 | */ |
||
106 | 8 | private function getPathFromArray($path) |
|
134 | |||
135 | /** |
||
136 | * Checks `$path` to see if it is either an array, a directory, or a file |
||
137 | * |
||
138 | * @param string|array $path |
||
139 | * |
||
140 | * @return array |
||
141 | * |
||
142 | * @throws EmptyDirectoryException If `$path` is an empty directory |
||
143 | * |
||
144 | * @throws FileNotFoundException If a file is not found at `$path` |
||
145 | */ |
||
146 | 20 | private function getValidPath($path) |
|
168 | } |
||
169 |