HistoryPlugin
in package
implements
EventSubscriberInterface, IteratorAggregate, Countable
Maintains a list of requests and responses sent using a request or client
Table of Contents
Interfaces
- EventSubscriberInterface
- An EventSubscriber knows himself what events he is interested in.
- IteratorAggregate
- Countable
Properties
- $limit : int
- $transactions : array<string|int, mixed>
Methods
- __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
stringadd()
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
HistoryPluginclear()
Clears the history
public
clear() : HistoryPlugin
Return values
HistoryPlugincount()
Get the number of requests in the history
public
count() : int
Return values
intgetAll()
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
ArrayIteratorgetLastRequest()
Get the last request sent
public
getLastRequest() : RequestInterface
Return values
RequestInterfacegetLastResponse()
Get the last response in the history
public
getLastResponse() : Response|null
Return values
Response|nullgetLimit()
Get the request limit
public
getLimit() : int
Return values
intgetSubscribedEvents()
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:
- array('eventName' => 'methodName')
- array('eventName' => array('methodName', $priority))
- array('eventName' => array(array('methodName1', $priority), array('methodName2')))
Return values
array<string|int, mixed> —The event names to listen to
onRequestSent()
public
onRequestSent(Event $event) : mixed
Parameters
- $event : Event
setLimit()
Set the max number of requests to store
public
setLimit(int $limit) : HistoryPlugin
Parameters
- $limit : int
-
Limit