@@ 116-125 (lines=10) @@ | ||
113 | * |
|
114 | * @return integer |
|
115 | */ |
|
116 | public function key() : int |
|
117 | { |
|
118 | if ($this->position === -1) { |
|
119 | $this->next(); |
|
120 | } |
|
121 | ||
122 | Util::ensure(false, empty($this->result), '\OutOfBoundsException', ['Collection contains no elements']); |
|
123 | ||
124 | return $this->offset + $this->position; |
|
125 | } |
|
126 | ||
127 | /** |
|
128 | * @see Iterator::valid() |
|
@@ 173-187 (lines=15) @@ | ||
170 | * |
|
171 | * @return array |
|
172 | */ |
|
173 | public function current() : array |
|
174 | { |
|
175 | if ($this->position === -1) { |
|
176 | $this->next(); |
|
177 | } |
|
178 | ||
179 | Util::ensure( |
|
180 | true, |
|
181 | array_key_exists($this->position, $this->result), |
|
182 | '\OutOfBoundsException', |
|
183 | ['Collection contains no element at current position'] |
|
184 | ); |
|
185 | ||
186 | return $this->result[$this->position]; |
|
187 | } |
|
188 | ||
189 | /** |
|
190 | * Returns the values from a single field this collection, identified by the given $key. |