1 | <?php |
||
7 | class InputCollectionMutator extends AbstractCollectionMutator |
||
8 | { |
||
9 | |||
10 | /** |
||
11 | * @param TransactionInputInterface[] $inputs |
||
12 | */ |
||
13 | 56 | public function __construct(array $inputs) |
|
14 | { |
||
15 | /** @var InputMutator[] $set */ |
||
16 | 56 | $set = []; |
|
17 | 56 | foreach ($inputs as $i => $input) { |
|
18 | 54 | $set[$i] = new InputMutator($input); |
|
19 | } |
||
20 | |||
21 | 56 | $this->set = \SplFixedArray::fromArray($set, false); |
|
22 | 56 | } |
|
23 | |||
24 | /** |
||
25 | * @return InputMutator |
||
26 | */ |
||
27 | 50 | public function current() |
|
28 | { |
||
29 | 50 | return $this->set->current(); |
|
30 | } |
||
31 | |||
32 | /** |
||
33 | * @param int $offset |
||
34 | * @return InputMutator |
||
35 | */ |
||
36 | 52 | public function offsetGet($offset) |
|
37 | { |
||
38 | 52 | if (!$this->set->offsetExists($offset)) { |
|
39 | throw new \OutOfRangeException('Input does not exist'); |
||
40 | } |
||
41 | |||
42 | 52 | return $this->set->offsetGet($offset); |
|
43 | } |
||
44 | |||
45 | /** |
||
46 | * @return TransactionInputInterface[] |
||
47 | */ |
||
48 | 54 | public function done() |
|
57 | |||
58 | /** |
||
59 | * @param int $start |
||
60 | * @param int $length |
||
61 | * @return $this |
||
62 | */ |
||
63 | 4 | public function slice($start, $length) |
|
73 | |||
74 | /** |
||
75 | * @return $this |
||
76 | */ |
||
77 | 2 | public function null() |
|
82 | |||
83 | /** |
||
84 | * @param TransactionInputInterface $input |
||
85 | * @return $this |
||
86 | */ |
||
87 | public function add(TransactionInputInterface $input) |
||
88 | { |
||
89 | $size = $this->set->getSize(); |
||
90 | $this->set->setSize($size + 1); |
||
91 | |||
92 | $this->set[$size] = new InputMutator($input); |
||
93 | return $this; |
||
94 | } |
||
95 | |||
96 | /** |
||
97 | * @param int $i |
||
98 | * @param TransactionInputInterface $input |
||
99 | * @return $this |
||
100 | */ |
||
101 | public function set($i, TransactionInputInterface $input) |
||
106 | } |
||
107 |