Conditions | 9 |
Paths | 5 |
Total Lines | 23 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 9 |
Changes | 0 |
1 | <?php |
||
32 | 2 | public function load(string $path) |
|
33 | { |
||
34 | 2 | $configToReturn = []; |
|
35 | 2 | foreach (new DirectoryIterator($path) as $file) { |
|
36 | 2 | $filename = $file->getFilename(); |
|
37 | 2 | if ($filename === '.' || $filename === '..') continue; |
|
38 | 2 | if ($file->isFile()) { |
|
39 | 2 | $name = $file->getBasename("." . $file->getExtension()); |
|
40 | 2 | foreach ($this->loaders as $loader) { |
|
41 | 2 | if ($loader->test($file->getRealPath())) { |
|
42 | 2 | if ($config = $loader->load($file->getRealPath())) { |
|
43 | 2 | $configToReturn[$name] = $config; |
|
44 | } |
||
45 | } |
||
46 | } |
||
47 | } else { |
||
48 | 1 | if (preg_match($this->pattern, $filename)) { |
|
49 | 2 | $configToReturn[$filename] = $this->load($file->getRealPath()); |
|
50 | } |
||
51 | } |
||
52 | } |
||
53 | 2 | return $configToReturn; |
|
54 | } |
||
55 | } |
||
56 |