1 | <?php |
||
8 | class TransactionCollection extends StaticCollection |
||
9 | { |
||
10 | /** |
||
11 | * Initialize a new collection with a list of transactions. |
||
12 | * |
||
13 | * @param TransactionInterface[] $transactions |
||
14 | */ |
||
15 | 174 | public function __construct(array $transactions = []) |
|
16 | { |
||
17 | 174 | foreach ($transactions as $tx) { |
|
18 | 144 | if (!$tx instanceof TransactionInterface) { |
|
19 | 6 | throw new \InvalidArgumentException('Must provide TransactionInterface[] to TransactionCollection'); |
|
20 | } |
||
21 | 174 | } |
|
22 | |||
23 | 168 | $this->set = \SplFixedArray::fromArray($transactions); |
|
24 | 168 | } |
|
25 | |||
26 | 6 | public function __clone() |
|
35 | |||
36 | /** |
||
37 | * @return TransactionInterface |
||
38 | */ |
||
39 | 66 | public function current() |
|
40 | { |
||
41 | 66 | return $this->set->current(); |
|
42 | } |
||
43 | |||
44 | /** |
||
45 | * @param int $offset |
||
46 | * @return TransactionInterface |
||
47 | */ |
||
48 | 48 | public function offsetGet($offset) |
|
56 | |||
57 | /** |
||
58 | * Returns all the transactions in the collection. |
||
59 | * |
||
60 | * @return TransactionInterface[] |
||
61 | */ |
||
62 | 30 | public function all() |
|
66 | } |
||
67 |