public function fetch($key, $default = null)
    {
        if ($this->hasKey($key)) {
            return $this[$key];
        } elseif ($default !== null) {
            if (is_callable($default)) {
                return $default($key);
            }

            return $default;
        }

        throw new InvalidArgumentException("Invalid key '$key'");
    }
public function fetch($key, $default = null)
    {
        if ($this->hasKey($key)) {
            return $this[$key];
        } elseif ($default !== null) {
            if (is_callable($default)) {
                return $default($key);
            }

            return $default;
        }

        throw new InvalidArgumentException("Invalid key '$key'");
    }
public function fetch ( $ key , $ default = null ) { if ( $ this -> hasKey ( $ key ) ) { return $ this [ $ key ] ; } elseif ( $ default !== null ) { if ( is_callable ( $ default ) ) { return $ default ( $ key ) ; } return $ default ; } throw new InvalidArgumentException ( "Invalid key '$key'" ) ; }
Get the value by the key. Throws exception when key is not set

@param string $key
@param mixed  $default either value or callable function

@return mixed the value for the given key

@throws InvalidArgumentException
Get the value by the key . Throws exception when key is not set