public function call($key, $callable)
    {
        if (!is_callable($callable)) {
            throw new \InvalidArgumentException('Not a valid callable.');
        }

        if ($this->exists($key)) {
            return $this->get($key);
        }

        $args = func_get_args();
        array_shift($args);
        array_shift($args);

        $value = call_user_func_array($callable, $args);

        $this->set($key, $value);

        return $value;
    }
public function call($key, $callable)
    {
        if (!is_callable($callable)) {
            throw new \InvalidArgumentException('Not a valid callable.');
        }

        if ($this->exists($key)) {
            return $this->get($key);
        }

        $args = func_get_args();
        array_shift($args);
        array_shift($args);

        $value = call_user_func_array($callable, $args);

        $this->set($key, $value);

        return $value;
    }
public function call ( $ key , $ callable ) { if ( ! is_callable ( $ callable ) ) { throw new \ InvalidArgumentException ( 'Not a valid callable.' ) ; } if ( $ this -> exists ( $ key ) ) { return $ this -> get ( $ key ) ; } $ args = func_get_args ( ) ; array_shift ( $ args ) ; array_shift ( $ args ) ; $ value = call_user_func_array ( $ callable , $ args ) ; $ this -> set ( $ key , $ value ) ; return $ value ; }
Fetch data from a callback if item not exists.

@param string   $key      The key of the item to fetch.
@param callable $callable The callback to fetch data.

@return  mixed
@throws \Psr\Cache\InvalidArgumentException
Fetch data from a callback if item not exists .