classFinder = $classFinder; $this->injectableFactory = $injectableFactory; } protected function getClassName(string $name) { return $this->classFinder->find('Services', $name, true); } 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; } }