PluginClient
in package
implements
HttpClient, HttpAsyncClient
FinalYes
The client managing plugins and providing a decorator around HTTP Clients.
Tags
Table of Contents
Interfaces
- HttpClient
- HttpAsyncClient
- Sends a PSR-7 Request in an asynchronous way by returning a Promise.
Properties
- $client : HttpAsyncClient
- An HTTP async client.
- $options : array<string|int, mixed>
- A list of options.
- $plugins : array<string|int, Plugin>
- The plugin chain.
Methods
- __construct() : mixed
- sendAsyncRequest() : Promise
- Sends a PSR-7 request in an asynchronous way.
- sendRequest() : ResponseInterface
- Sends a PSR-7 request and returns a PSR-7 response.
- configure() : array<string|int, mixed>
- Configure the plugin client.
- createPluginChain() : callable(RequestInterface): Promise
- Create the plugin chain.
Properties
$client
An HTTP async client.
private
HttpAsyncClient
$client
$options
A list of options.
private
array<string|int, mixed>
$options
$plugins
The plugin chain.
private
array<string|int, Plugin>
$plugins
Methods
__construct()
public
__construct(ClientInterface|HttpAsyncClient $client[, array<string|int, Plugin> $plugins = [] ][, array{'max_restarts'?: int} $options = [] ]) : mixed
Parameters
- $client : ClientInterface|HttpAsyncClient
-
An HTTP async client
- $plugins : array<string|int, Plugin> = []
-
A plugin chain
- $options : array{'max_restarts'?: int} = []
sendAsyncRequest()
Sends a PSR-7 request in an asynchronous way.
public
sendAsyncRequest(RequestInterface $request) : Promise
Parameters
- $request : RequestInterface
Return values
Promise —resolves a PSR-7 Response or fails with an Http\Client\Exception
sendRequest()
Sends a PSR-7 request and returns a PSR-7 response.
public
sendRequest(RequestInterface $request) : ResponseInterface
Parameters
- $request : RequestInterface
Return values
ResponseInterfaceconfigure()
Configure the plugin client.
private
configure([array<string|int, mixed> $options = [] ]) : array<string|int, mixed>
Parameters
- $options : array<string|int, mixed> = []
Return values
array<string|int, mixed>createPluginChain()
Create the plugin chain.
private
createPluginChain(array<string|int, Plugin> $plugins, callable $clientCallable) : callable(RequestInterface): Promise
Parameters
- $plugins : array<string|int, Plugin>
-
A plugin chain
- $clientCallable : callable
-
Callable making the HTTP call