MockHandler
in package
implements
Countable
Handler that returns responses or throw exceptions from a queue.
Interfaces, Classes and Traits
- Countable
Table of Contents
- $lastOptions : mixed
- $lastRequest : mixed
- $onFulfilled : mixed
- $onRejected : mixed
- $queue : mixed
- __construct() : mixed
- The passed in value must be an array of {@see Psr7\Http\Message\ResponseInterface} objects, Exceptions, callables, or Promises.
- __invoke() : mixed
- append() : mixed
- Adds one or more variadic requests, exceptions, callables, or promises to the queue.
- count() : int
- Returns the number of remaining items in the queue.
- createWithMiddleware() : HandlerStack
- Creates a new MockHandler that uses the default handler stack list of middlewares.
- getLastOptions() : array<string|int, mixed>
- Get the last received request options.
- getLastRequest() : RequestInterface
- Get the last received request.
- reset() : mixed
- invokeStats() : mixed
Properties
$lastOptions
private
mixed
$lastOptions
$lastRequest
private
mixed
$lastRequest
$onFulfilled
private
mixed
$onFulfilled
$onRejected
private
mixed
$onRejected
$queue
private
mixed
$queue
= []
Methods
__construct()
The passed in value must be an array of {@see Psr7\Http\Message\ResponseInterface} objects, Exceptions, callables, or Promises.
public
__construct([array<string|int, mixed> $queue = null ][, callable $onFulfilled = null ][, callable $onRejected = null ]) : mixed
Parameters
- $queue : array<string|int, mixed> = null
- $onFulfilled : callable = null
-
Callback to invoke when the return value is fulfilled.
- $onRejected : callable = null
-
Callback to invoke when the return value is rejected.
Return values
mixed —__invoke()
public
__invoke(RequestInterface $request, array<string|int, mixed> $options) : mixed
Parameters
- $request : RequestInterface
- $options : array<string|int, mixed>
Return values
mixed —append()
Adds one or more variadic requests, exceptions, callables, or promises to the queue.
public
append() : mixed
Return values
mixed —count()
Returns the number of remaining items in the queue.
public
count() : int
Return values
int —createWithMiddleware()
Creates a new MockHandler that uses the default handler stack list of middlewares.
public
static createWithMiddleware([array<string|int, mixed> $queue = null ][, callable $onFulfilled = null ][, callable $onRejected = null ]) : HandlerStack
Parameters
- $queue : array<string|int, mixed> = null
-
Array of responses, callables, or exceptions.
- $onFulfilled : callable = null
-
Callback to invoke when the return value is fulfilled.
- $onRejected : callable = null
-
Callback to invoke when the return value is rejected.
Return values
HandlerStack —getLastOptions()
Get the last received request options.
public
getLastOptions() : array<string|int, mixed>
Return values
array<string|int, mixed> —getLastRequest()
Get the last received request.
public
getLastRequest() : RequestInterface
Return values
RequestInterface —reset()
public
reset() : mixed
Return values
mixed —invokeStats()
private
invokeStats(RequestInterface $request, array<string|int, mixed> $options[, ResponseInterface $response = null ][, mixed $reason = null ]) : mixed
Parameters
- $request : RequestInterface
- $options : array<string|int, mixed>
- $response : ResponseInterface = null
- $reason : mixed = null