HistoryPlugin
in package
implements
EventSubscriberInterface, IteratorAggregate, Countable
Maintains a list of requests and responses sent using a request or client
Interfaces, Classes and Traits
- EventSubscriberInterface
- An EventSubscriber knows itself what events it is interested in.
- IteratorAggregate
- Countable
Table of Contents
- $limit : int
- $transactions : array<string|int, mixed>
- __toString() : string
- Convert to a string that contains all request and response headers
- add() : HistoryPlugin
- Add a request to the history
- clear() : HistoryPlugin
- Clears the history
- count() : int
- Get the number of requests in the history
- getAll() : array<string|int, mixed>
- Get all of the raw transactions in the form of an array of associative arrays containing 'request' and 'response' keys.
- getIterator() : ArrayIterator
- Get the requests in the history
- getLastRequest() : RequestInterface
- Get the last request sent
- getLastResponse() : Response|null
- Get the last response in the history
- getLimit() : int
- Get the request limit
- getSubscribedEvents() : array<string|int, mixed>
- Returns an array of event names this subscriber wants to listen to.
- onRequestSent() : mixed
- setLimit() : HistoryPlugin
- Set the max number of requests to store
Properties
$limit
protected
int
$limit
= 10
The maximum number of requests to maintain in the history
$transactions
protected
array<string|int, mixed>
$transactions
= array()
Requests and responses that have passed through the plugin
Methods
__toString()
Convert to a string that contains all request and response headers
public
__toString() : string
Return values
string —add()
Add a request to the history
public
add(RequestInterface $request[, Response $response = null ]) : HistoryPlugin
Parameters
- $request : RequestInterface
-
Request to add
- $response : Response = null
-
Response of the request
Return values
HistoryPlugin —clear()
Clears the history
public
clear() : HistoryPlugin
Return values
HistoryPlugin —count()
Get the number of requests in the history
public
count() : int
Return values
int —getAll()
Get all of the raw transactions in the form of an array of associative arrays containing 'request' and 'response' keys.
public
getAll() : array<string|int, mixed>
Return values
array<string|int, mixed> —getIterator()
Get the requests in the history
public
getIterator() : ArrayIterator
Return values
ArrayIterator —getLastRequest()
Get the last request sent
public
getLastRequest() : RequestInterface
Return values
RequestInterface —getLastResponse()
Get the last response in the history
public
getLastResponse() : Response|null
Return values
Response|null —getLimit()
Get the request limit
public
getLimit() : int
Return values
int —getSubscribedEvents()
Returns an array of event names this subscriber wants to listen to.
public
static getSubscribedEvents() : array<string|int, mixed>
The array keys are event names and the value can be:
- The method name to call (priority defaults to 0)
- An array composed of the method name to call and the priority
- An array of arrays composed of the method names to call and respective priorities, or 0 if unset
For instance:
- ['eventName' => 'methodName']
- ['eventName' => ['methodName', $priority]]
- ['eventName' => [['methodName1', $priority], ['methodName2']]]
The code must not depend on runtime state as it will only be called at compile time. All logic depending on runtime state must be put into the individual methods handling the events.
Return values
array<string|int, mixed> —The event names to listen to
onRequestSent()
public
onRequestSent(Event $event) : mixed
Parameters
- $event : Event
Return values
mixed —setLimit()
Set the max number of requests to store
public
setLimit(int $limit) : HistoryPlugin
Parameters
- $limit : int
-
Limit