Set the accepted HTTP methods for this route.

@param array $methods The HTTP methods to accept.
@return $this
@throws \InvalidArgumentException
766758
public function setMethods(array $methods)
    {
        $methods = array_map('strtoupper', $methods);
        $diff = array_diff($methods, static::VALID_METHODS);
        if ($diff !== []) {
            throw new InvalidArgumentException(
                sprintf('Invalid HTTP method received. %s is invalid.', implode(', ', $diff))
            );
        }
        $this->defaults['_method'] = $methods;

        return $this;
    }
749366
public function withMethod($method)
    {
        $method = strtoupper($method);

        if (false === in_array($method, ['GET', 'HEAD', 'POST', 'PUT', 'OPTIONS', 'DELETE'])) {
            throw new \InvalidArgumentException(
                sprintf('Invalid HTTP method: %s', $method)
            );
        }

        return $this->_clone('method', $method);
    }
1127867
protected function validateMethod($method)
    {
        if (null === $method) {
            return;
        }

        if (!is_string($method)) {
            throw new InvalidArgumentException('HTTP method must be a string.');
        }

        if (!preg_match('/^[!#$%&\'*+.^_`\|~0-9a-z-]+$/i', $method)) {
            throw new InvalidArgumentException(sprintf('Invalid HTTP method "%s"', $method));
        }
    }
1101502
public function setMethod($method)
	{
		$method = strtolower($method);

		if (!array_key_exists($method, static::$methods)) {
			throw new \InvalidArgumentException("Method [$method] not a valid HTTP method.");
		}

		if ($this->data && !static::$methods[$method]) {
			throw new \LogicException('Request has POST data, but tried changing HTTP method to one that does not allow POST data');
		}

		$this->method = $method;

		return $this;
	}
786914
public function setHttpMethod($method)
    {
        $allowedMethods = array(
             'POST',
             'PUT',
             'GET',
             'DELETE',
             'PATCH'
        );
        if (!in_array(strtoupper($method), $allowedMethods)) {
            throw new \InvalidArgumentException('Provided method not allowed');
        }
        $this->httpMethod = strtoupper($method);
        return $this;
    }
980405
public static function fromRouteFailure(?array $methods): self
    {
        $result = new self();
        $result->success = false;
        $result->allowedMethods = $methods;

        return $result;
    }
453306
public function setAllowedHttpMethods(array $allowedHttpMethods = null)
    {
        $results = null;
        if (is_array($allowedHttpMethods)) {
            $results = array_map(function ($method) {
                $method = trim($method);
                $method = strtolower($method);

                return $method;
            }, $allowedHttpMethods);

            $results = array_combine($results, $results);
        }
        $this->allowedHttpMethods = $results;

        return $this;
    }
1081441
public function setMethod(string $method) : Request
    {
        $this->method = $this->fixMethodCase($method);

        return $this;
    }
1206346
protected function setOnResource(array $methods)
    {
        if ( count($methods) <= 2
            && array_filter($methods, function($item) { return is_callable($item); }) 
        )
            ##! 'on_resource' => ['dump_debug' => function($resource) {k($resource);}]
            $methods = array($methods);

        foreach($methods as $method) {
            $name = null;
            if (is_array($method)) {
                if (count($method) === 2) {
                    ##! ['method_name', \Closure]
                    $name = $method[0]; $fn = $method[1];
                } elseif (array_values($method) !== $method) {
                    ##! ['method_name' => \Closure]
                    $name = key($method);
                    $fn = current($method);
                }
            }

            if ($name === null)
                throw new \InvalidArgumentException(
                    'Unknown Method Type Provided For '.\Poirot\Std\flatten($method)
                );

            $this->onResourceAvailable()->addMethod($name, $fn);
        }
    }
892149
public function setRules(array $rules)
    {
        $this->validators = [];
        foreach ($rules as $rule) {
            if (is_array($rule[0]) && is_string($rule[1])) {
                continue;
            }
            throw new InvalidArgumentException('Bad validation rule');
        }
        $this->rules = $rules;

        return $this;
    }
483563
public function method(string $method, string ...$methods): self
    {
        array_unshift($methods, $method);

        return $this->setAllowedMethods($methods);
    }
542135
public function setMethods($methods)
    {
        $this->methods = array_map('strtoupper', (array) $methods);
        $this->compiled = null;

        return $this;
    }
107000
public function setup(array $parameters)
	{
		$parameters = $this->prepareParameters($parameters);

		// Make sure, that 'driver' parameter is handled first.
		if ( isset($parameters['driver']) ) {
			$this->setDriver($parameters['driver']);
			unset($parameters['driver']);
		}

		foreach ( $parameters as $name => $value ) {
			$method = 'set' . ucfirst($name);

			if ( !method_exists($this, $method) ) {
				throw new \InvalidArgumentException('Unable to set unknown parameter "' . $name . '"');
			}

			$this->$method($value);
		}

		return $this;
	}
648945
public function setMethod($method)
	{
		$method = strtoupper($method);
		
		if(!preg_match("'^[A-Z]{2,}$'", $method))
		{
			throw new \InvalidArgumentException(sprintf('Invalid HTTP request method: "%s"', $method));
		}
		
		$this->method = $method;

		return $this;
	}
791138
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;
    }
987738
public function addMethods(array $methods)
    {
        foreach ($methods as $key => $method) {
            $this->addMethod($method, $key);
        }
        return $this;
    }
729089
public function setMethod($method)
    {
        if (in_array(strtolower($method), ['publish', 'patch', 'move', 'swap'])) {
            $this->headers['X-HTTP-Method-Override'] = $method;
            $this->method = 'POST';
        } else {
            $this->method = strtoupper($method);
        }
    }