pock

ReplyFactoryInterface

Creates a response at request time for PockBuilder::replyWithFactory().

final class EchoReplyFactory implements ReplyFactoryInterface
{
    public function createReply(RequestInterface $request, PockResponseBuilder $builder): ResponseInterface
    {
        return $builder->withBody((string) $request->getBody())->getResponse();
    }
}
Tags
category

ReplyFactoryInterface

Table of Contents

Methods

createReply()  : ResponseInterface
Build a PSR-7 response for the matched request.

Methods

createReply()

Build a PSR-7 response for the matched request.

public createReply(RequestInterface $request, PockResponseBuilder $responseBuilder) : ResponseInterface

If this method throws any exception, it will be treated as with the PockBuilder::throwException call.

Parameters
$request : RequestInterface
$responseBuilder : PockResponseBuilder
Tags
see
PockBuilder::throwException()
throws
Throwable
Return values
ResponseInterface
On this page

Search results