public function config($key, $value = null) {
        if (is_array($key))
            $this->config = $key + $this->config;
        else {
            if ($value !== null) $this->config[$key] = $value;
            if (!isset($this->config[$key]))
                throw new \Exception("Configuration key `type` is not set");
            return $this->config[$key];
        }
    }