1 | <?php |
||
17 | class Config extends Collection implements ConfigInterface |
||
18 | { |
||
19 | /** |
||
20 | * Array of parser instances |
||
21 | * @var array |
||
22 | */ |
||
23 | protected static $parsers = []; |
||
24 | |||
25 | /** |
||
26 | * Array of supported file format parsers |
||
27 | * @var array |
||
28 | */ |
||
29 | protected static $supportedFileParsers = [ |
||
30 | PHPParser::class, |
||
31 | IniParser::class, |
||
32 | JsonParser::class, |
||
33 | XmlParser::class, |
||
34 | YamlParser::class |
||
35 | ]; |
||
36 | |||
37 | public function __construct($path = null) |
||
42 | |||
43 | /** |
||
44 | * {@inheritdoc} |
||
45 | */ |
||
46 | public function load($path) |
||
54 | |||
55 | /** |
||
56 | * {@inheritdoc} |
||
57 | */ |
||
58 | public function dump($file) |
||
63 | |||
64 | /** |
||
65 | * Parse a configuration file or directory to an array |
||
66 | * @param string $path |
||
67 | * @return array |
||
68 | * @deprecated |
||
69 | */ |
||
70 | public function parse($path) |
||
74 | |||
75 | /** |
||
76 | * Add a custom parser |
||
77 | * @param ParserInterface $parser |
||
78 | */ |
||
79 | public static function addParser(ParserInterface $parser) |
||
85 | |||
86 | /** |
||
87 | * Parse a configuration file or directory to an array |
||
88 | * @param string $path |
||
89 | * @return array |
||
90 | */ |
||
91 | protected function parseConfiguration($path) |
||
101 | |||
102 | /** |
||
103 | * finds all supported configuration files at the directory |
||
104 | * @param string $path |
||
105 | * @throws InvalidFileException |
||
106 | * @return array |
||
107 | */ |
||
108 | protected function findConfigurationFiles($path) |
||
123 | |||
124 | /** |
||
125 | * Gets a file parser by its extension |
||
126 | * @param string $extension |
||
127 | * @throws UnsupportedFormatException |
||
128 | * @return ParserInterface |
||
129 | */ |
||
130 | protected static function getParser($extension) |
||
143 | } |
||
144 |