public function config($key = null, $value = null)
    {
        // when key is null, then return all config.
        if (! $key) return $this->config;

        // when last char is ".", then behavior for array.
        $is_array = false;
        if (substr($key, -1) === '.') {
            $is_array = true;
            $key = substr($key, 0, -1);
        }

        // set config.
        if ($value !== null) {
            if ($is_array) {
                if (! array_key_exists($key, $this->config)) $this->config[$key] = array();
                array_push($this->config[$key], $value);
            } else {
                $this->config[$key] = $value;
            }
        }

        if (substr($key, -1) === '*') {
            $config = [];
            $key_quoted = preg_quote(substr($key, 0, -1), '/');
            foreach ($this->config as $_key => $_val) {
                if (preg_match("/^{$key_quoted}.*/", $_key)) {
                    $config[$_key] = $_val;
                }
            }
            return $config;
        } else {
            return array_key_exists($key, $this->config) ? $this->config[$key] : null;
        }
    }