|null */ private ?array $worlds = null; /** * @return array */ public function all(): array { if ($this->worlds === null) { $this->worlds = []; foreach (config('image-worlds.paths') as $path) { foreach (glob(rtrim($path, '/\\').'/*/world.json') ?: [] as $file) { $manifest = ImageWorldManifest::fromFile($file); $this->worlds[$manifest->key] = $manifest; } } ksort($this->worlds); } return $this->worlds; } public function get(?string $key): ?ImageWorldManifest { if ($key === null || $key === '') { return null; } return $this->all()[$key] ?? null; } /** * Key => name, for a select in the admin. * * @return array */ public function options(): array { return array_map(fn (ImageWorldManifest $world): string => $world->name, $this->all()); } }