injections[$name] = $object; } public function __call($methodName, $args) { if (strpos($methodName, 'get') === 0) { $injectionName = lcfirst(substr($methodName, 3)); if (isset($this->injections[$injectionName])) { return $this->getInjection($injectionName); } } throw new \BadMethodCallException('Method ' . $methodName . ' does not exist'); } protected function getInjection(string $name) : object { $object = $this->injections[$name] ?? null; if (!$object) throw new \Exception("Injection {$name} is not set."); return $object; } }