resourceTypes[$name] = $type; } public function createResource(string $type, array $options) { if (!array_key_exists($type, $this->resourceTypes)) { return null; } $resource = new $this->resourceTypes[$type]($options); return $resource; } public function createNamedResource(string $name, string $type, array $options) { if (array_key_exists($name, $this->namedResources)) { fprintf(STDERR, "warning: Redefining named resource %s\n", $name); } $resource = $this->createResource($type, $options); $this->namedResources[$name] = $resource; return $resource; } public function getNamedResource(string $name) { return $this->namedResources[$name] ?? null; } public function getAllNamedResources(): array { return $this->namedResources; } public function getAllResourceTypes(): array { return $this->resourceTypes; } }