kahlan\Scope::given PHP Method

given() public method

Sets a lazy loaded data.
public given ( string $name, Closur\Closure $closure ) : object
$name string The lazy loaded variable name.
$closure Closur\Closure The lazily executed closure.
return object
    public function given($name, $closure)
    {
        if (isset(static::$blacklist[$name])) {
            throw new Exception("Sorry `{$name}` is a reserved keyword, it can't be used as a scope variable.");
        }
        $given = new Given($closure);
        if (array_key_exists($name, $this->_given)) {
            $given->{$name} = $this->_given[$name](static::current());
        }
        $this->_given[$name] = $given;
        return $this;
    }