phasync
Request / withBody

Method

Request::withBody

Return an instance with the specified message body.

Description#

public Request::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