TradesResponse
extends IteratorIterator
in package
Iterable collection of trade responses
This class provides an iterable wrapper around a collection of TradeResponse objects representing executed DEX trades. It extends IteratorIterator to enable efficient traversal of trades returned from Horizon API endpoints. The collection supports iteration, counting, array conversion, and dynamic addition of trade records.
Used by TradesPageResponse to hold the trades contained in a single page of results. Each item in the collection represents an executed exchange between two assets with details about the participants, amounts, price, and timing.
Tags
Table of Contents
Methods
- __construct() : mixed
- Constructs a new trades collection
- add() : void
- Adds a trade response to the collection
- count() : int
- Gets the total number of trades in this collection
- current() : TradeResponse
- Gets the current trade in the iteration
- toArray() : array<string|int, TradeResponse>
Methods
__construct()
Constructs a new trades collection
public
__construct(TradeResponse ...$trades) : mixed
Parameters
- $trades : TradeResponse
-
Variable number of trade responses
add()
Adds a trade response to the collection
public
add(TradeResponse $trade) : void
Parameters
- $trade : TradeResponse
-
The trade response to add
count()
Gets the total number of trades in this collection
public
count() : int
Return values
int —The count of trades
current()
Gets the current trade in the iteration
public
current() : TradeResponse
Return values
TradeResponse —The current trade response
toArray()
public
toArray() : array<string|int, TradeResponse>