public function setMethod(string $method = null)
    {
        if ($method === null) {
            $method = $this->server->get('REQUEST_METHOD', RequestMethods::GET);

            if ($method == RequestMethods::POST) {
                if (($overrideMethod = $this->server->get('X-HTTP-METHOD-OVERRIDE')) !== null) {
                    $method = $overrideMethod;
                } elseif (($overrideMethod = $this->post->get('_method')) !== null) {
                    $method = $overrideMethod;
                } elseif (($overrideMethod = $this->query->get('_method')) !== null) {
                    $method = $overrideMethod;
                }

                $this->originalMethodCollection = $this->post;
            }
        }

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

        $method = strtoupper($method);

        if (!in_array($method, self::$validMethods)) {
            throw new InvalidArgumentException(
                sprintf(
                    'Invalid HTTP method "%s"',
                    $method
                )
            );
        }

        $this->method = $method;
    }
public function setMethod(string $method = null)
    {
        if ($method === null) {
            $method = $this->server->get('REQUEST_METHOD', RequestMethods::GET);

            if ($method == RequestMethods::POST) {
                if (($overrideMethod = $this->server->get('X-HTTP-METHOD-OVERRIDE')) !== null) {
                    $method = $overrideMethod;
                } elseif (($overrideMethod = $this->post->get('_method')) !== null) {
                    $method = $overrideMethod;
                } elseif (($overrideMethod = $this->query->get('_method')) !== null) {
                    $method = $overrideMethod;
                }

                $this->originalMethodCollection = $this->post;
            }
        }

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

        $method = strtoupper($method);

        if (!in_array($method, self::$validMethods)) {
            throw new InvalidArgumentException(
                sprintf(
                    'Invalid HTTP method "%s"',
                    $method
                )
            );
        }

        $this->method = $method;
    }
public function setMethod ( string $ method = null ) { if ( $ method === null ) { $ method = $ this -> server -> get ( 'REQUEST_METHOD' , RequestMethods :: GET ) ; if ( $ method == RequestMethods :: POST ) { if ( ( $ overrideMethod = $ this -> server -> get ( 'X-HTTP-METHOD-OVERRIDE' ) ) !== null ) { $ method = $ overrideMethod ; } elseif ( ( $ overrideMethod = $ this -> post -> get ( '_method' ) ) !== null ) { $ method = $ overrideMethod ; } elseif ( ( $ overrideMethod = $ this -> query -> get ( '_method' ) ) !== null ) { $ method = $ overrideMethod ; } $ this -> originalMethodCollection = $ this -> post ; } } if ( ! is_string ( $ method ) ) { throw new InvalidArgumentException ( sprintf ( 'HTTP method must be string, %s provided' , is_object ( $ method ) ? get_class ( $ method ) : gettype ( $ method ) ) ) ; } $ method = strtoupper ( $ method ) ; if ( ! in_array ( $ method , self :: $ validMethods ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid HTTP method "%s"' , $ method ) ) ; } $ this -> method = $ method ; }
Sets the method
If no input is specified, then it is automatically set using headers

@param string|null $method The method to set, otherwise null to automatically set the method
@throws InvalidArgumentException Thrown if the method is not an acceptable one
Sets the method If no input is specified then it is automatically set using headers