@param string[] $allowedMethods An array of allowed request methods. Default is GET, POST, PUT, PATCH, HEAD,
OPTIONS, DELETE.

@return self

@throws \Error If the array contains non-strings, empty method names, or does not contain GET or HEAD.
965286
public function withAllowedMethods(array $allowedMethods): self
    {
        foreach ($allowedMethods as $key => $method) {
            if (!\is_string($method)) {
                throw new \Error(
                    \sprintf(
                        "Invalid type at key %s of allowed methods array: %s",
                        $key,
                        \is_object($method) ? \get_class($method) : \gettype($method)
                    )
                );
            }

            if ($method === "") {
                throw new \Error(
                    "Invalid empty HTTP method at key {$key} of allowed methods array"
                );
            }
        }

        $allowedMethods = \array_unique($allowedMethods);

        if (!\in_array("GET", $allowedMethods, true)) {
            throw new \Error(
                "Servers must support GET as an allowed HTTP method"
            );
        }

        if (!\in_array("HEAD", $allowedMethods, true)) {
            throw new \Error(
                "Servers must support HEAD as an allowed HTTP method"
            );
        }

        $new = clone $this;
        $new->allowedMethods = $allowedMethods;

        return $new;
    }
345670
public function set( $method )
	{
		$method		= strtoupper( $method );
		if( !in_array( $method, self::$methods ) )
			throw new BadMethodCallException( 'HTTP method "%s" is not supported' );
		$this->method	= $method;
		return $this;
	}
784197
public function allowMethod(string $method): Route
    {
        if (!in_array($method, self::$supportedMethods)) {
            throw new UnsupportedMethodException($method);
        }

        $this->methods[] = $method;

        return $this;
    }
681420
public function setRequestMethods(array $requestMethods) {

	    $requestMethods = array_map('strtoupper', $requestMethods);

        $allowedMethods	= ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'];

        foreach($requestMethods as $requestMethod) {
			if(!in_array($requestMethod, $allowedMethods)) {
				throw new \InvalidArgumentException(sprintf("Invalid request method '%s'.", $requestMethod));
			}
		}

		$this->requestMethods = $requestMethods;
		return $this;

	}
726122
public Collection<String> getAllowedMethods(String requestMethod) {

		Constraint.ensureNotEmpty(requestMethod, String.format("Invalid method '%s'", requestMethod));
		Set<String> rtAllowedMethods = new HashSet<String>(allowedMethods);
		rtAllowedMethods.add(requestMethod.toUpperCase());

		return rtAllowedMethods;
	}
383407
public function addAllowedMethods(array $methods): MethodNotAllowed
    {
        $this->allowedMethods = array_merge($this->allowedMethods, $methods);

        return $this;
    }
945961
public function setMethod($method)
	{
		if ($method === null || !is_array($method) || empty($method)) {
			throw new InvalidArgumentException('No method provided');
		}

		foreach ($method as $m) {
			if (!in_array($m, array('GET','POST','PUT','PATCH','DELETE'))) {
				throw new InvalidArgumentException('Method not allowed. allowed methods: GET, POST, PUT, PATCH, DELETE');
			}
		}

		$this->method = $method;

		return $this;
	}
781627
public function allowMethods(array $excepted)
    {
        if (count($excepted) == 0) {
            throw new AccessControlException(
                'Parameter is empty.',
                E_USER_ERROR
            );
        }

        return $this->push('Access-Control-Allow-Methods', implode(', ', $excepted));
    }
795428
public static function fromMethodFailure(array $allowedMethods)
    {
        $matchResult = new self();
        $matchResult->type = 'methodFailure';
        $matchResult->allowedMethods = $allowedMethods;
        return $matchResult;
    }
1099605
public void setRequestMethods(String... requestMethods) {
        this.allowedMethods = requestMethods;
        if (this.allowedMethods != null) {
            for (int i = 0; i < this.allowedMethods.length; i++) {
                this.allowedMethods[i] = this.allowedMethods[i].toUpperCase();
            }
        }
    }
505321
public function setMethod($method)
    {
        parent::setMethod($method);
        if ($method !== 'GET') {
            switch ($method) {
                case 'POST':
                    $this->setOption(CURLOPT_POST, true);
                    break;
                default:
                    $this->setOption(CURLOPT_CUSTOMREQUEST, $this->method);
                    break;
            }
        }

        return $this;
    }
1349508
public void setAllowedMethods(String[] methods)
    {
        StringBuffer b = new StringBuffer();
        _methods=methods;
        _methodMap.clear();
        for (int i=0;i<methods.length;i++)
        {
            _methodMap.put(methods[i],methods[i]);
            if (i>0)
                b.append(',');
            b.append(methods[i]);
        }
        _allowed=b.toString();
    }
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;
    }
936535
public function setAllowedHosts($allowedHosts)
    {
        if (is_string($allowedHosts)) {
            $allowedHosts = preg_split('/ *, */', $allowedHosts);
        }
        $this->allowedHosts = $allowedHosts;
        return $this;
    }
352915
private static function methodIsAllowed($httpMethod)
    {
        $allowedMethods = [
            self::METHOD_GET,
            self::METHOD_POST,
            self::METHOD_PUT,
            self::METHOD_PATCH,
            self::METHOD_DELETE,
        ];

        return in_array($httpMethod, $allowedMethods, true);
    }
188748
public function setAllowMethods($methods)
    {
        $methods = (array) $methods;

        $methods = array_map('strtoupper', $methods);

        $this->allowMethods = $methods;

        return $this;
    }
344804
function allowedMethods(methods) {
  // default values
  var methodsAllowed = { 'GET': true, 'POST': false, 'PUT': false, 'HEAD': false, 'DELETE': false  };
  // check and override if one of the default methods
  for (var key in methods) {
    var newKey = key.toUpperCase();
    if ( methodsAllowed[newKey]!=undefined) {
      methodsAllowed[newKey] = Boolean(methods[key]);
    }
  }
  return methodsAllowed;
}