public function withMethod($method)
    {
        $method = strtoupper($method);
        $knownMethods = [
            'HEAD', 'OPTIONS', 'GET', 'POST', 'PUT',
            'DELETE', 'CONNECT', 'TRACE', 'PATCH', 'PURGE'
        ];

        if (! in_array($method, $knownMethods)) {
            throw new InvalidArgumentException(
                "Invalid or unknown method name."
            );
        }

        $message = clone $this;
        $message->method = $method;
        return $message;
    }
public function withMethod($method)
    {
        $method = strtoupper($method);
        $knownMethods = [
            'HEAD', 'OPTIONS', 'GET', 'POST', 'PUT',
            'DELETE', 'CONNECT', 'TRACE', 'PATCH', 'PURGE'
        ];

        if (! in_array($method, $knownMethods)) {
            throw new InvalidArgumentException(
                "Invalid or unknown method name."
            );
        }

        $message = clone $this;
        $message->method = $method;
        return $message;
    }
public function withMethod ( $ method ) { $ method = strtoupper ( $ method ) ; $ knownMethods = [ 'HEAD' , 'OPTIONS' , 'GET' , 'POST' , 'PUT' , 'DELETE' , 'CONNECT' , 'TRACE' , 'PATCH' , 'PURGE' ] ; if ( ! in_array ( $ method , $ knownMethods ) ) { throw new InvalidArgumentException ( "Invalid or unknown method name." ) ; } $ message = clone $ this ; $ message -> method = $ method ; return $ message ; }
Return an instance with the provided HTTP method.

@param string $method Case-sensitive method.
@return static
@throws InvalidArgumentException for invalid HTTP methods.
Return an instance with the provided HTTP method .