| 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 | 1240 | public function __construct(array $outputs = []) |
|
| 17 | { |
||
| 18 | 1240 | $this->set = new \SplFixedArray(count($outputs)); |
|
| 19 | 1240 | foreach ($outputs as $idx => $output) { |
|
| 20 | 404 | if (!$output instanceof TransactionOutputInterface) { |
|
| 21 | 6 | throw new \InvalidArgumentException('Must provide TransactionOutputInterface[] to TransactionOutputCollection'); |
|
| 22 | } |
||
| 23 | 398 | $this->set->offsetSet($idx, $output); |
|
| 24 | 1234 | } |
|
| 25 | 1234 | } |
|
| 26 | |||
| 27 | 110 | public function __clone() |
|
| 28 | { |
||
| 29 | 110 | $outputs = $this->set; |
|
| 30 | 110 | $this->set = new \SplFixedArray(count($outputs)); |
|
| 31 | |||
| 32 | 110 | foreach ($outputs as $idx => $output) { |
|
| 33 | 42 | $this->set->offsetSet($idx, $output); |
|
| 34 | 110 | } |
|
| 35 | 110 | } |
|
| 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 | 170 | public function offsetGet($offset) |
|
| 57 | } |
||
| 58 |