phasync
ServerRequest / withBody

Method

ServerRequest::withBody

Return an instance with the specified message body.

Description#

public ServerRequest::withBody(
    $body
): MessageInterface

The body MUST be a StreamInterface object.

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return a new instance that has the new body stream.

Parameters#

$body
Body.

Return values#

MessageInterface

Errors / Exceptions#

ExceptionWhen
InvalidArgumentExceptionWhen the body is not valid.