Guzzle 7.4.2

MockHandler
in package
implements Countable

Handler that returns responses or throw exceptions from a queue.

Tags
final

Interfaces, Classes, Traits and Enums

Countable

Table of Contents

$lastOptions  : array<string|int, mixed>
$lastRequest  : RequestInterface|null
$onFulfilled  : callable|null
$onRejected  : callable|null
$queue  : array<string|int, mixed>
__construct()  : mixed
The passed in value must be an array of {@see \Psr\Http\Message\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

Methods

__construct()

The passed in value must be an array of {@see \Psr\Http\Message\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.

Return values
mixed

__invoke()

public __invoke(RequestInterface $request, array<string|int, mixed> $options) : PromiseInterface
Parameters
$request : RequestInterface
$options : array<string|int, mixed>
Return values
PromiseInterface

append()

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

public append(mixed ...$values) : void
Parameters
$values : mixed
Return values
void

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>|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
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|null
Return values
RequestInterface|null

reset()

public reset() : void
Return values
void

invokeStats()

private invokeStats(RequestInterface $request, array<string|int, mixed> $options[, ResponseInterface $response = null ][, mixed $reason = null ]) : void
Parameters
$request : RequestInterface
$options : array<string|int, mixed>
$response : ResponseInterface = null
$reason : mixed = null

Promise or reason.

Return values
void

Search results