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