\GuzzleHttp\HandlerMockHandler

Handler that returns responses or throw exceptions from a queue.

Summary

Methods
Properties
Constants
createWithMiddleware()
__construct()
__invoke()
append()
getLastRequest()
getLastOptions()
count()
reset()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
invokeStats()
$queue
$lastRequest
$lastOptions
$onFulfilled
$onRejected
N/A

Properties

$queue

$queue : array

Type

array

$lastOptions

$lastOptions : array

Type

array

$onFulfilled

$onFulfilled : callable|null

Type

callable|null

Methods

createWithMiddleware()

createWithMiddleware(array|null  $queue = null, callable|null  $onFulfilled = null, callable|null  $onRejected = null) : \GuzzleHttp\HandlerStack

Creates a new MockHandler that uses the default handler stack list of middlewares.

Parameters

array|null $queue

Array of responses, callables, or exceptions.

callable|null $onFulfilled

Callback to invoke when the return value is fulfilled.

callable|null $onRejected

Callback to invoke when the return value is rejected.

Returns

\GuzzleHttp\HandlerStack —

__construct()

__construct(array<int,mixed>|null  $queue = null, callable|null  $onFulfilled = null, callable|null  $onRejected = null) : mixed

The passed in value must be an array of {@see \Psr\Http\Message\ResponseInterface} objects, Exceptions, callables, or Promises.

Parameters

array|null $queue

The parameters to be passed to the append function, as an indexed array.

callable|null $onFulfilled

Callback to invoke when the return value is fulfilled.

callable|null $onRejected

Callback to invoke when the return value is rejected.

Returns

mixed —

__invoke()

__invoke(\Psr\Http\Message\RequestInterface  $request, array  $options) : \GuzzleHttp\Promise\PromiseInterface

Parameters

\Psr\Http\Message\RequestInterface $request
array $options

Returns

\GuzzleHttp\Promise\PromiseInterface —

append()

append(mixed  ...$values) : void

Adds one or more variadic requests, exceptions, callables, or promises to the queue.

Parameters

mixed $values variadic

getLastRequest()

getLastRequest() : ?\Psr\Http\Message\RequestInterface

Get the last received request.

Returns

?\Psr\Http\Message\RequestInterface —

getLastOptions()

getLastOptions() : array

Get the last received request options.

Returns

array —

count()

count() : int

Returns the number of remaining items in the queue.

Returns

int —

reset()

reset() : void

invokeStats()

invokeStats(\Psr\Http\Message\RequestInterface  $request, array  $options, \Psr\Http\Message\ResponseInterface  $response = null, mixed  $reason = null) : void

Parameters

\Psr\Http\Message\RequestInterface $request
array $options
\Psr\Http\Message\ResponseInterface $response
mixed $reason

Promise or reason.