phasync
Request / withMethod

Method

Request::withMethod

Return an instance with the provided HTTP method.

Description#

public Request::withMethod(
    $method
): RequestInterface

While HTTP method names are typically all uppercase characters, HTTP method names are case-sensitive and thus implementations SHOULD NOT modify the given string.

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the changed request method.

Parameters#

$method
Case-sensitive method.

Return values#

RequestInterface

Errors / Exceptions#

ExceptionWhen
InvalidArgumentExceptionFor invalid HTTP methods.