protected function validateMethod($method)
    {
        if ($method === null) {
            return $method;
        }

        if (!is_string($method)) {
            throw new \InvalidArgumentException('Method should be a string.');
        }

        $method = strtoupper($method);

        if (!in_array($method, $this->allowMethods)) {
            throw new \InvalidArgumentException('Invalid HTTP method: ' . $method);
        }

        return $method;
    }