public function setMethod(string $method = null)
    {
        if ($method === null) {
            $method = $this->server->get('REQUEST_METHOD', RequestMethods::GET);

            if ($method == RequestMethods::POST) {
                if (($overrideMethod = $this->server->get('X-HTTP-METHOD-OVERRIDE')) !== null) {
                    $method = $overrideMethod;
                } elseif (($overrideMethod = $this->post->get('_method')) !== null) {
                    $method = $overrideMethod;
                } elseif (($overrideMethod = $this->query->get('_method')) !== null) {
                    $method = $overrideMethod;
                }

                $this->originalMethodCollection = $this->post;
            }
        }

        if (!is_string($method)) {
            throw new InvalidArgumentException(
                sprintf(
                    'HTTP method must be string, %s provided',
                    is_object($method) ? get_class($method) : gettype($method)
                )
            );
        }

        $method = strtoupper($method);

        if (!in_array($method, self::$validMethods)) {
            throw new InvalidArgumentException(
                sprintf(
                    'Invalid HTTP method "%s"',
                    $method
                )
            );
        }

        $this->method = $method;
    }