CallbackReplyFactory
in package
implements
ReplyFactoryInterface
Adapts a response callback to ReplyFactoryInterface.
PockBuilder::replyWithCallback() constructs this adapter automatically.
$factory = new CallbackReplyFactory(
static function (RequestInterface $request, PockResponseBuilder $builder) {
return $builder->withBody((string) $request->getBody())->getResponse();
}
);
Tags
Table of Contents
Interfaces
- ReplyFactoryInterface
- Creates a response at request time for PockBuilder::replyWithFactory().
Methods
- __construct() : mixed
- Store a callback with the ReplyFactoryInterface::createReply() signature.
- createReply() : ResponseInterface
- Build a PSR-7 response for the matched request.
Methods
__construct()
Store a callback with the ReplyFactoryInterface::createReply() signature.
public
__construct(callable $callback) : mixed
Parameters
- $callback : callable
createReply()
Build a PSR-7 response for the matched request.
public
createReply(RequestInterface $request, PockResponseBuilder $responseBuilder) : ResponseInterface
Parameters
- $request : RequestInterface
- $responseBuilder : PockResponseBuilder