Kahlan\Box\Box::wrap PHP Method

wrap() public method

Returns a dependency container.
public wrap ( string $name ) : mixed
$name string The name of the definition.
return mixed The shared variable or an new instance.
    public function wrap($name)
    {
        if (!isset($this->_definitions[$name])) {
            throw new BoxException("Unexisting `{$name}` definition dependency.");
        }
        if (!$this->_definitions[$name]['definition'] instanceof Closure) {
            throw new BoxException("Error `{$name}` is not a closure definition dependency can't be wrapped.");
        }
        $params = func_get_args();
        array_shift($params);
        $wrapper = $this->_classes['wrapper'];
        return new $wrapper(['box' => $this, 'name' => $name, 'params' => $params]);
    }