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