| 1 | <?php |
||
| 18 | class ObjectModel extends Model implements \Iterator, \Countable |
||
| 19 | { |
||
| 20 | protected $collection = []; |
||
| 21 | protected $innerCounter = -1; |
||
| 22 | |||
| 23 | 41 | public function current() |
|
| 24 | { |
||
| 25 | 41 | if (is_array(current($this->collection))) { |
|
| 26 | return new ObjectModel(current($this->collection)); |
||
| 27 | } |
||
| 28 | |||
| 29 | 41 | return current($this->collection); |
|
| 30 | } |
||
| 31 | |||
| 32 | 26 | public function next() |
|
| 33 | { |
||
| 34 | 26 | $this->innerCounter++; |
|
| 35 | 26 | return next($this->collection); |
|
| 36 | } |
||
| 37 | |||
| 38 | 1 | public function key() |
|
| 39 | { |
||
| 40 | 1 | return key($this->collection); |
|
| 41 | } |
||
| 42 | |||
| 43 | 1 | public function valid() |
|
| 44 | { |
||
| 45 | 1 | return $this->innerCounter < count($this->collection); |
|
| 46 | } |
||
| 47 | |||
| 48 | 1 | public function rewind() |
|
| 49 | { |
||
| 50 | 1 | $this->innerCounter = 0; |
|
| 51 | 1 | reset($this->collection); |
|
| 52 | 1 | return; |
|
| 53 | } |
||
| 54 | |||
| 55 | public function count() |
||
| 59 | } |
||
| 60 |