classFinder = $classFinder; $this->injectableFactory = $injectableFactory; } /** * @return ?class-string */ private function getClassName(string $name): ?string { return $this->classFinder->find('Services', $name); } public function checkExists(string $name): bool { $className = $this->getClassName($name); if (!$className) { return false; } return true; } public function create(string $name): object { $className = $this->getClassName($name); if (!$className) { throw new Error("Service '{$name}' was not found."); } $obj = $this->injectableFactory->create($className); // deprecated if (method_exists($obj, 'prepare')) { $obj->prepare(); } return $obj; } }