1 | <?php |
||
8 | class TransactionOutputCollection extends StaticCollection |
||
9 | { |
||
10 | |||
11 | /** |
||
12 | * Initialize a new collection with a list of outputs. |
||
13 | * |
||
14 | * @param TransactionOutputInterface[] $outputs |
||
15 | */ |
||
16 | 1242 | public function __construct(array $outputs = []) |
|
17 | { |
||
18 | 1242 | $this->set = new \SplFixedArray(count($outputs)); |
|
19 | 1242 | foreach ($outputs as $idx => $output) { |
|
20 | 405 | if (!$output instanceof TransactionOutputInterface) { |
|
21 | 6 | throw new \InvalidArgumentException('Must provide TransactionOutputInterface[] to TransactionOutputCollection'); |
|
22 | } |
||
23 | 399 | $this->set->offsetSet($idx, $output); |
|
24 | 1236 | } |
|
25 | 1236 | } |
|
26 | |||
27 | 111 | public function __clone() |
|
28 | { |
||
29 | 111 | $outputs = $this->set; |
|
30 | 111 | $this->set = new \SplFixedArray(count($outputs)); |
|
31 | |||
32 | 111 | foreach ($outputs as $idx => $output) { |
|
33 | 42 | $this->set->offsetSet($idx, $output); |
|
34 | 111 | } |
|
35 | 111 | } |
|
36 | |||
37 | /** |
||
38 | * @return TransactionOutputInterface |
||
39 | */ |
||
40 | 78 | public function current() |
|
41 | { |
||
42 | 78 | return $this->set->current(); |
|
43 | } |
||
44 | |||
45 | /** |
||
46 | * @param int $offset |
||
47 | * @return TransactionOutputInterface |
||
48 | */ |
||
49 | 171 | public function offsetGet($offset) |
|
57 | } |
||
58 |