Open Monograph Press  3.3.0
GuzzleHttp\Handler\MockHandler Class Reference
Inheritance diagram for GuzzleHttp\Handler\MockHandler:

Public Member Functions

 __construct (array $queue=null, callable $onFulfilled=null, callable $onRejected=null)
 
 __invoke (RequestInterface $request, array $options)
 
 append ()
 
 count ()
 
 getLastOptions ()
 
 getLastRequest ()
 
 reset ()
 

Static Public Member Functions

static createWithMiddleware (array $queue=null, callable $onFulfilled=null, callable $onRejected=null)
 

Detailed Description

Handler that returns responses or throw exceptions from a queue.

Definition at line 15 of file MockHandler.php.

Constructor & Destructor Documentation

◆ __construct()

GuzzleHttp\Handler\MockHandler::__construct ( array  $queue = null,
callable  $onFulfilled = null,
callable  $onRejected = null 
)

The passed in value must be an array of {

See also
Psr7\Http\Message\ResponseInterface} objects, Exceptions, callables, or Promises.
Parameters
array$queue
callable$onFulfilledCallback to invoke when the return value is fulfilled.
callable$onRejectedCallback to invoke when the return value is rejected.

Definition at line 50 of file MockHandler.php.

Member Function Documentation

◆ __invoke()

GuzzleHttp\Handler\MockHandler::__invoke ( RequestInterface  $request,
array  $options 
)

Definition at line 63 of file MockHandler.php.

References GuzzleHttp\Promise\queue().

◆ append()

GuzzleHttp\Handler\MockHandler::append ( )

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

Definition at line 132 of file MockHandler.php.

References GuzzleHttp\describe_type(), and GuzzleHttp\Promise\queue().

◆ count()

GuzzleHttp\Handler\MockHandler::count ( )

Returns the number of remaining items in the queue.

Returns
int

Definition at line 173 of file MockHandler.php.

References GuzzleHttp\Promise\queue().

◆ createWithMiddleware()

static GuzzleHttp\Handler\MockHandler::createWithMiddleware ( array  $queue = null,
callable  $onFulfilled = null,
callable  $onRejected = null 
)
static

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

Parameters
array$queueArray of responses, callables, or exceptions.
callable$onFulfilledCallback to invoke when the return value is fulfilled.
callable$onRejectedCallback to invoke when the return value is rejected.
Returns
HandlerStack

Definition at line 33 of file MockHandler.php.

References GuzzleHttp\HandlerStack\create().

◆ getLastOptions()

GuzzleHttp\Handler\MockHandler::getLastOptions ( )

Get the last received request options.

Returns
array

Definition at line 163 of file MockHandler.php.

◆ getLastRequest()

GuzzleHttp\Handler\MockHandler::getLastRequest ( )

Get the last received request.

Returns
RequestInterface

Definition at line 153 of file MockHandler.php.

◆ reset()

GuzzleHttp\Handler\MockHandler::reset ( )

Definition at line 178 of file MockHandler.php.

References GuzzleHttp\Promise\queue().


The documentation for this class was generated from the following file: