Conditions | 6 |
Paths | 5 |
Total Lines | 32 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 42 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
19 | public function load(string $resourcesPath): array |
||
20 | { |
||
21 | $fileSystem = new Filesystem(); |
||
22 | |||
23 | if (!$fileSystem->exists($resourcesPath)) { |
||
24 | throw new FileNotFoundException(null, 0, null, $resourcesPath); |
||
25 | } |
||
26 | |||
27 | if (!is_dir($resourcesPath)) { |
||
28 | throw new Exception(sprintf('The resources path %s should be a directory', $resourcesPath)); |
||
29 | } |
||
30 | $finder = new Finder(); |
||
31 | $finder |
||
32 | ->files() |
||
33 | ->name('*.yaml') |
||
34 | ->in($resourcesPath) |
||
35 | ; |
||
36 | $data = []; |
||
37 | |||
38 | foreach ($finder as $fileInfo) { |
||
39 | $yaml = Yaml::parse(file_get_contents($fileInfo->getRealPath())); |
||
40 | |||
41 | if (!is_array($yaml)) { |
||
42 | continue; |
||
43 | } |
||
44 | |||
45 | foreach ($yaml as $name => $admin) { |
||
46 | $data[$name] = $admin; |
||
47 | } |
||
48 | } |
||
49 | |||
50 | return $data; |
||
51 | } |
||
53 |