Inpsyde\MultilingualPress\Service\AddOnlyContainer::offsetGet PHP Method

offsetGet() public method

Returns the value or factory callback with the given name.
Since: 3.0.0
public offsetGet ( string $name ) : mixed
$name string The name of a value or factory callback.
return mixed The value or factory callback with the given name.
    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];
    }