1 | <?php |
||
21 | class Config extends AbstractConfig |
||
22 | { |
||
23 | /** |
||
24 | * All formats supported by Config. |
||
25 | * |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $supportedParsers = [ |
||
29 | 'Noodlehaus\Parser\Php', |
||
30 | 'Noodlehaus\Parser\Ini', |
||
31 | 'Noodlehaus\Parser\Json', |
||
32 | 'Noodlehaus\Parser\Xml', |
||
33 | 'Noodlehaus\Parser\Yaml' |
||
34 | ]; |
||
35 | |||
36 | /** |
||
37 | * Static method for loading a Config instance. |
||
38 | * |
||
39 | * @param string|array $values Filenames or string with configuration |
||
40 | * @param ParserInterface $parser Configuration parser |
||
41 | * @param bool $string Enable loading from string |
||
42 | * |
||
43 | * @return Config |
||
44 | */ |
||
45 | 3 | public static function load($values, $parser = null, $string = false) |
|
49 | |||
50 | /** |
||
51 | * Loads a Config instance. |
||
52 | * |
||
53 | * @param string|array $values Filenames or string with configuration |
||
54 | * @param ParserInterface $parser Configuration parser |
||
55 | * @param bool $string Enable loading from string |
||
56 | */ |
||
57 | 39 | public function __construct($values, ParserInterface $parser = null, $string = false) |
|
67 | |||
68 | /** |
||
69 | * Loads configuration from file. |
||
70 | * |
||
71 | * @param string|array $path Filenames or directories with configuration |
||
72 | * @param ParserInterface $parser Configuration parser |
||
73 | * |
||
74 | * @throws EmptyDirectoryException If `$path` is an empty directory |
||
75 | */ |
||
76 | 39 | protected function loadFromFile($path, ParserInterface $parser = null) |
|
107 | |||
108 | /** |
||
109 | * Loads configuration from string. |
||
110 | * |
||
111 | * @param string $configuration String with configuration |
||
112 | * @param ParserInterface $parser Configuration parser |
||
113 | */ |
||
114 | 3 | protected function loadFromString($configuration, ParserInterface $parser) |
|
121 | |||
122 | /** |
||
123 | * Gets a parser for a given file extension. |
||
124 | * |
||
125 | * @param string $extension |
||
126 | * |
||
127 | * @return Noodlehaus\Parser\ParserInterface |
||
128 | * |
||
129 | * @throws UnsupportedFormatException If `$extension` is an unsupported file format |
||
130 | */ |
||
131 | 27 | protected function getParser($extension) |
|
142 | |||
143 | /** |
||
144 | * Gets an array of paths |
||
145 | * |
||
146 | * @param array $path |
||
147 | * |
||
148 | * @return array |
||
149 | * |
||
150 | * @throws FileNotFoundException If a file is not found at `$path` |
||
151 | */ |
||
152 | 12 | protected function getPathFromArray($path) |
|
181 | |||
182 | /** |
||
183 | * Checks `$path` to see if it is either an array, a directory, or a file. |
||
184 | * |
||
185 | * @param string|array $path |
||
186 | * |
||
187 | * @return array |
||
188 | * |
||
189 | * @throws EmptyDirectoryException If `$path` is an empty directory |
||
190 | * |
||
191 | * @throws FileNotFoundException If a file is not found at `$path` |
||
192 | */ |
||
193 | 33 | protected function getValidPath($path) |
|
217 | } |
||
218 |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.