readPath($path); } } } private function readPath(string $path) { $iter = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $path ) ); /** @var SplFileInfo $iteminfo */ foreach ($iter as $itempath=>$iteminfo) { if (!fnmatch("*.json", $itempath)) continue; $json = file_get_contents($itempath); $parsed = json_decode($json, true); $this->services[$itempath] = $parsed; } usort($this->services, function ($a,$b) { return $a['name'] <=> $b['name']; }); } public function findServiceByName(string $name): ?array { foreach ($this->services as $service) { if ($service['name'] === $name) return $service; } return null; } public function findAllServices(): array { return $this->services; } }