/**
* Returns the value or factory callback with the given name.
*
* @since 3.0.0
*
* @param string $name The name of a value or factory callback.
*
* @return mixed The value or factory callback with the given name.
*
* @throws ContainerValueNotSetException if there is no value or factory callback with the given name.
* @throws ContainerBootstrappedException if a not shared value or factory callback is to be accessed on a
* bootstrapped container.
*/
public function offsetGet($name)
{
if (!$this->offsetExists($name)) {
throw ContainerValueNotSetException::for_name($name, 'read');
}
if ($this->is_bootstrapped && !array_key_exists($name, $this->shared)) {
throw ContainerBootstrappedException::for_name($name, 'read');
}
if (!array_key_exists($name, $this->values)) {
$factory = $this->factories[$name];
$this->values[$name] = $factory($this);
if ($this->is_locked) {
unset($this->factories[$name]);
}
}
return $this->values[$name];
}