container[$name] = $value; } /** * Get a dependency * * @access public * @param string $name Unique identifier for the service/parameter * @return mixed The value of the parameter or an object * @throws RuntimeException If the identifier is not found */ public function __get($name) { if (isset($this->container[$name])) { if (is_callable($this->container[$name])) { return $this->container[$name](); } else { return $this->container[$name]; } } throw new \RuntimeException('Identifier not found in the registry: '.$name); } /** * Return a shared instance of a dependency * * @access public * @param string $name Unique identifier for the service/parameter * @return mixed Same object instance of the dependency */ public function shared($name) { if (! isset($this->instances[$name])) { $this->instances[$name] = $this->$name; } return $this->instances[$name]; } }