Check if an HTTP method is allowed by checking the Allow response header

@param string $method Method to check

@return bool
173425
public function isMethodAllowed($method)
    {
        $allow = $this->getHeader('Allow');
        if ($allow) {
            foreach (explode(',', $allow) as $allowable) {
                if (!strcasecmp(trim($allowable), $method)) {
                    return true;
                }
            }
        }

        return false;
    }
1209328
public function checkPermission($method, $context)
    {
        if (!is_string($method)) {
            throw new \TypeError('The method parameter must be a string.');
        }
        if (!$method) {
            throw new \InvalidArgumentException('The method parameter cannot be empty.');
        }

        $currentRequest = $this->requestStack->getCurrentRequest();

        if (!$currentRequest) {
            return false;
        }

        return strcasecmp($currentRequest->getMethod(), $method) == 0;
    }
1364187
public function excludedForMethod($method) : bool
    {
        if (empty($this->only) && empty($this->except)) {
            return false;
        }

        return (!empty($this->only) && !in_array($method, $this->only)) ||
            (!empty($this->except) && in_array($method, $this->except));
    }
905087
function validateMethod (method) {
  if (!method) {
    return option.some('HTTP method is not specified')
  }
  if (typeof method !== 'string') {
    return option.some('HTTP method should be type of string')
  }
  if (supportedMethods.indexOf(method.toUpperCase()) < 0) {
    return option.some(`Http method ${method} is not supported`)
  }
  return option.none
}
118837
public function isSupportedMethod($method) {
        if (!is_string($method)) throw new IllegalTypeException('Illegal type of parameter $method: '.gettype($method));
        return isset($this->methods[strtoupper($method)]);
    }
812021
public function allowsMethod($method_id)
    {
        if (!$this->method_ids) {
            return false;
        }

        if (preg_match('/^[^:]+::[^:]+$/', $method_id)) {
            $method_stub = '*::' . explode('::', $method_id)[1];

            foreach ($this->method_ids as $config_method_id) {
                if ($config_method_id === $method_id) {
                    return true;
                }

                if ($config_method_id === $method_stub) {
                    return true;
                }

                if ($config_method_id[0] === '/' && preg_match($config_method_id, $method_id)) {
                    return true;
                }
            }

            return false;
        }

        return in_array($method_id, $this->method_ids);
    }
798465
protected function _isMethodExists($method)
    {
        $return = method_exists($this, $method);
        if ($return) {
            ## it must be exists also be public accessible
            $ref    = $this->_newReflection();
            $ref    = $ref->getMethod($method);
            $return = $return && $ref->isPublic();
        }

        $ignored = $this->doWhichMethodIgnored();
        return $return && !in_array($method, $ignored);
    }
995892
private function shouldProxiedMethodReturn(\ReflectionMethod $method)
    {
        if ( ! $method->hasReturnType()) {
            return true;
        }

        return 'void' !== strtolower($this->formatType($method->getReturnType(), $method));
    }
1000230
protected function validateMethod($method)
    {
        $valid = [
            'GET'     => true,
            'POST'    => true,
            'DELETE'  => true,
            'PUT'     => true,
            'PATCH'   => true,
            'HEAD'    => true,
            'OPTIONS' => true,
        ];

        if (!isset($valid[$method])) {
            throw new InvalidArgumentException(
                'Invalid method version. Must be one of: GET, POST, DELETE, PUT, PATCH, HEAD or OPTIONS'
            );
        }
    }
357073
private static function validate_method( $method ) {

		if ( $method && isset( $method[0] ) && isset( $method[1] ) ) {
			if ( method_exists( $method[0], $method[1] ) ) {
				return true;
			}
		}

		return false;
	}
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);
    }
67937
public function isMethodAllowed(string $method): bool
    {
        if (\in_array($method, $this->methods, true)) {
            return true;
        }

        if ($method === HttpMethod::HEAD) {
            return \in_array(HttpMethod::GET, $this->methods, true);
        }

        return false;
    }
127695
public function validateRequest($uri = null, $method = null)
	{
		$endpoint = false;

		if (is_null($uri))
		{
			$uri = "";
		}

		if (is_null($method))
		{
			$method = $_SERVER['REQUEST_METHOD'];
		}

		$parts = parse_url($uri);

		$path = trim($parts['path'], '/');

		if ($path == $this->_request_token_path)
		{
			$this->_provider->isRequestTokenEndpoint(true);
		}
		else if ($path == $this->_access_token_path)
		{
			$header = '';

			if (isset($_SERVER['HTTP_AUTHORIZATION']))
			{
				$header = $_SERVER['HTTP_AUTHORIZATION'];
			}

			// @FIXME: header check is inexact and could give false positives
			// @FIXME: pecl oauth provider doesn't handle x_auth in header
			// @FIXME: api application should convert xauth variables in
			//         header to form/query data as workaround
			// @FIXME: this code is here for future use if/when pecl oauth
			//         provider is fixed

			if (isset($_GET['x_auth_mode'])
				|| isset($_GET['x_auth_username'])
				|| isset($_GET['x_auth_password'])
				|| isset($_POST['x_auth_mode'])
				|| isset($_POST['x_auth_username'])
				|| isset($_POST['x_auth_password'])
				|| !strpos($header, 'x_auth_mode')
				|| !strpos($header, 'x_auth_username')
				|| !strpos($header, 'x_auth_password'))
			{
				$this->_provider->is2LeggedEndpoint(true);
				//$this->_provider->addRequiredParameter ('x_auth_mode');
				//$this->_provider->addRequiredParameter ('x_auth_username');
				//$this->_provider->addRequiredParameter ('x_auth_password');
			}
		}

		try
		{
			$this->_provider->checkOAuthRequest($uri, $method);

			return true;
		}
		catch (OAuthException $E)
		{
		}

		// No attempt was made to sign this, let it pass as such
		if (($this->_provider->consumer_key === null)
			&& ($this->_provider->consumer_secret === null)
			&& ($this->_provider->nonce === null)
			&& ($this->_provider->token === null)
			&& ($this->_provider->token_secret === null)
			&& ($this->_provider->timestamp === null)
			&& ($this->_provider->version === null)
			&& ($this->_provider->signature_method === null)
			&& ($this->_provider->callback === null)
			&& (empty($this->_provider->signature))
		)
		{
			return true;
		}

		// request to authorize path can have token and callback params, but are unsigned
		if ($path == $this->_authorize_path)
		{
			if (($this->_provider->consumer_key === null)
				&& ($this->_provider->consumer_secret === null)
				&& ($this->_provider->nonce === null)
				&& ($this->_provider->token_secret === null)
				&& ($this->_provider->timestamp === null)
				&& ($this->_provider->version === null)
				&& ($this->_provider->signature_method === null)
				&& (empty($this->_provider->signature))
				)
			{
				return true;
			}
		}

		$message = OAuthProvider::reportProblem($E, false);

		// request signed without token is allowed to pass
		if ($message == "oauth_problem=token_rejected")
		{
			if (($this->_provider->consumer_key !== null)
				&& ($this->_provider->consumer_secret !== null)
				&& ($this->_provider->nonce !== null)
				&& (empty($this->_provider->token))
				&& (empty($this->_provider->token_secret))
				&& ($this->_provider->timestamp !== null)
				&& ($this->_provider->version !== null)
				&& ($this->_provider->signature_method !== null)
				&& (!empty($this->_provider->signature))
			)
			{
				return true;
			}
		}

		$status = 401;
		$reason = 'Unauthorized';

		if ($message == "oauth_problem=signature_method_rejected")
		{
			$reason = 'Bad Request';
			$status = 400;
		}
		else if (strpos($message, "oauth_problem=parameter_absent") !== false)
		{
			$reason = 'Bad Request';
			$status = 400;
		}
		else if ($message == "oauth_problem=unknown_problem&code=503")
		{
			$reason = 'Bad Request';
			$status = 400;
		}

		$result['message'] = $message;
		$result['status']  = $status;
		$result['reason']  = $reason;

		return $result;
	}
744385
public function checkMethodRequiresLogin($method)
    {
        $methodsThatRequireLogin = array_merge($this->loginRequiredFor, $this->requiresLoginFor());

        return in_array($method, $methodsThatRequireLogin);
    }
487112
private function safeMethod (&$target,string $method) {
		if (method_exists($target, $method)) {
			$target->$method();
			return true;
		}
		else {
			return false;
		}
	}
167963
public function setMethod($method)
    {
        if(!in_array(strtoupper($method), $this->allowedMethods)) {
          throw new \InvalidArgumentException("The HTTP Client doesn't accept $method requests.");
        }

        $this->method = $method;
        return $this;
    }
1058039
protected function _isMethodExists($method)
    {
        if ( $return = method_exists($this, $method) ) {
            ## it must be exists also be public accessible
            $ref    = $this->_newReflection();
            $ref    = $ref->getMethod($method);
            $return = $ref->isPublic();
        }

        return $return;
    }