Client
in package
implements
ClientInterface, HttpClient, HttpAsyncClient
PSR-18 and HTTPlug client that resolves requests against an ordered list of pock mocks.
Obtain this client from PockBuilder so pending definitions are closed correctly.
$client = $pock->getClient();
$response = $client->sendRequest($request);
$promise = $client->sendAsyncRequest($request);
Tags
Table of Contents
Interfaces
- ClientInterface
- HttpClient
- HttpAsyncClient
Methods
- __construct() : mixed
- Create a client from prepared mocks and an optional PSR-18 fallback.
- doSendRequest() : ResponseInterface
- Send a request through the asynchronous implementation and unwrap its result.
- sendAsyncRequest() : Promise
- sendRequest() : ResponseInterface
Methods
__construct()
Create a client from prepared mocks and an optional PSR-18 fallback.
public
__construct(array<string|int, MockInterface> $mocks[, ClientInterface|null $fallbackClient = null ]) : mixed
Parameters
- $mocks : array<string|int, MockInterface>
-
Ordered request expectations.
- $fallbackClient : ClientInterface|null = null
-
Client used when no expectation matches.
doSendRequest()
Send a request through the asynchronous implementation and unwrap its result.
public
doSendRequest(RequestInterface $request) : ResponseInterface
$response = $client->doSendRequest($request);
Parameters
- $request : RequestInterface
Tags
Return values
ResponseInterfacesendAsyncRequest()
public
sendAsyncRequest(RequestInterface $request) : Promise
Parameters
- $request : RequestInterface
Tags
Return values
PromisesendRequest()
public
sendRequest(RequestInterface $request) : ResponseInterface
Parameters
- $request : RequestInterface