Check the HTTP method is allowed.

@param string $httpMethod

@return bool
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);
    }
618511
protected function filterMethod($method)
    {
        if ($method === null) {
            return $method;
        }

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

        $method = strtoupper($method);
        if (preg_match("/^[!#$%&'*+.^_`|~0-9a-z-]+$/i", $method) !== 1) {
            throw new InvalidMethodException($this, $method);
        }

        return $method;
    }
894633
public function getMethod()
    {
        if (empty($this->method)) {
            $this->method = strtolower($this->httpRequest()->getRequestMethod());
        }

        return $this->method;
    }
1193521
protected function checkFallbacks($routes, $httpMethod)
    {
        $additional = array(Route::ANY);

        if ($httpMethod === Route::HEAD) {
            $additional[] = Route::GET;
        }

        foreach ($additional as $method) {
            if (isset($routes[$method])) {
                return $method;
            }
        }

        $this->matchedRoute = $routes;

        throw new HttpMethodNotAllowedException('Allow: ' . implode(', ', array_keys($routes)));
    }
522481
protected function isScopeMethodUsable(ReflectionMethod $method)
    {
        // Scope methods with more or less required parameters than the query, should not be used.
        if ($method->getNumberOfRequiredParameters() != 1) {
            return false;
        }

        // If the required parameter is not the first, don't use it (safeguard)
        if ( ! ($firstParameter = head($method->getParameters())) || $firstParameter->isOptional()) {
            // @codeCoverageIgnoreStart
            return false;
            // @codeCoverageIgnoreEnd
        }

        $scopeName = camel_case(substr($method->name, 5));

        // Ignore scope methods with an explicity ignore cms docblock tag
        $cmsTags = $this->getCmsDocBlockTags($method);

        if (    array_get($cmsTags, 'ignore')
            ||  (   ! array_get($cmsTags, 'scope')
                &&  in_array($scopeName, $this->getIgnoredScopeNames() )
            )
        ) {
            return false;
        }

        return true;
    }
319031
protected function matchSimilarRoute($httpMethod, $path)
    {
        $dm = [];

        if (($sm = $this->checkStaticRouteInOtherMethods($httpMethod, $path))
                || ($dm = $this->checkDynamicRouteInOtherMethods($httpMethod, $path))) {
            throw new MethodNotAllowedException($httpMethod, $path, array_merge((array) $sm, (array) $dm));
        }

        throw new NotFoundException;
    }
1284463
private function isRequestMethodOk(Envelope $envelope, Request $request): bool
    {
        if (in_array($request->getMethod(), $this->allowedMethods)) {
            return true;
        }

        $envelope
            ->set('code', Code::UNIMPLEMENTED)
            ->set('http_code', HttpCode::HTTP_METHOD_NOT_ALLOWED())
            ->set('error_name', 'MethodNotAllowed')
            ->set(
                'error_message',
                sprintf('You can only use HTTP [%s] on this service.', implode(',', $this->allowedMethods))
            );

        return false;
    }
259881
private function matchRequestMethod(
        string $method = null,
        array $supported = null
    ) {
        if ($supported && !in_array($method, $supported)) {
            return false;
        }

        return true;
    }
623857
protected function isMethodAllowed($method)
    {
        // Make sure $method is string
        if (!is_string($method)) {
            throw new InvalidArgumentException(
                '$method must be string'
            );
        }

        // If method is simple method, always allow
        if ($this->isSimpleMethod($method)) {
            return true;
        }

        return in_array(
            $method,
            $this->config['allowMethods'],
            true
        );
    }
1258088
protected function method($method)
    {
        if (strtolower($this->request->getMethod()) != strtolower($method)) {
            throw new MethodNotAllowedException('No matching method for HTTP method "'.$this->request->getMethod().'"');
        }
        return true;
    }
572714
protected function detectMethod(HttpRequest $request)
	{
		$requestMethod = $request->getMethod();
		if ($requestMethod !== 'POST') {
			return $request->getMethod();
		}

		$method = $request->getHeader(self::HTTP_HEADER_OVERRIDE);
		if (isset($method)) {
			return strtoupper($method);
		}

		$method = $request->getQuery(self::QUERY_PARAM_OVERRIDE);
		if (isset($method)) {
			return strtoupper($method);
		}

		return $requestMethod;
	}
1151762
protected function inAllowedMethods($method)
    {
        $allowedMethods = collect(config('admin.operation_log.allowed_methods'))->filter();

        if ($allowedMethods->isEmpty()) {
            return true;
        }

        return $allowedMethods->map(function ($method) {
            return strtoupper($method);
        })->contains($method);
    }
676134
protected function allowedCache($method)
    {
        $cacheEnabled = config('repository.cache.enabled', true);

        if (!$cacheEnabled) {
            return false;
        }

        $cacheOnly = isset($this->cacheOnly) ? $this->cacheOnly : config('repository.cache.allowed.only', null);
        $cacheExcept = isset($this->cacheExcept) ? $this->cacheExcept : config('repository.cache.allowed.except', null);

        if (is_array($cacheOnly)) {
            return in_array($method, $cacheOnly);
        }

        if (is_array($cacheExcept)) {
            return !in_array($method, $cacheExcept);
        }

        if (is_null($cacheOnly) && is_null($cacheExcept)) {
            return true;
        }

        return false;
    }
1114152
public function getAllowedMethods()
    {
        $result = [];
        if ($this->get) {
            $result[] = HttpMethods::GET;
        }
        if ($this->post) {
            $result[] = HttpMethods::POST;
        }
        if ($this->put) {
            $result[] = HttpMethods::PUT;
        }
        if ($this->path) {
            $result[] = HttpMethods::PATCH;
        }
        if ($this->delete) {
            $result[] = HttpMethods::DELETE;
        }
        if ($this->head) {
            $result[] = HttpMethods::HEAD;
        }
        if ($this->options) {
            $result[] = HttpMethods::OPTIONS;
        }

        return $result;
    }
860750
private function checkHttpStatusCodeRule()
    {
        if (isset($this->httpStatusCode)
            && $this->httpStatusCode >= 500
            && $this->httpStatusCode <= 599
        ) {
            $this->log[] = 'Disallowed by HTTP status code 5xx';
            return true;
        }
        return false;
    }
850254
public function isMethodSafe(/* $andCacheable = true */)
    {
        if (!func_num_args() || func_get_arg(0)) {
            // This deprecation should be turned into a BadMethodCallException in 4.0 (without adding the argument in the signature)
            // then setting $andCacheable to false should be deprecated in 4.1
            @trigger_error('Checking only for cacheable HTTP methods with Symfony\Component\HttpFoundation\Request::isMethodSafe() is deprecated since version 3.2 and will throw an exception in 4.0. Disable checking only for cacheable methods by calling the method with `false` as first argument or use the Request::isMethodCacheable() instead.', E_USER_DEPRECATED);

            return in_array($this->getMethod(), array('GET', 'HEAD'));
        }

        return in_array($this->getMethod(), array('GET', 'HEAD', 'OPTIONS', 'TRACE'));
    }
652644
protected function getValidMethod($method)
    {
        $method = strtolower($method);

        if (strpos(self::HTTP_METHODS, $method) === false) {
            throw new MethodNotSupportedException($method);
        }

        return $method;
    }