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