1 | <?php |
||
7 | class CollectionIterator extends ArrayIterator |
||
8 | { |
||
9 | /** |
||
10 | * @var Collection |
||
11 | */ |
||
12 | private $collection; |
||
13 | |||
14 | private $data = []; |
||
15 | |||
16 | /** |
||
17 | * CollectionIterator constructor. |
||
18 | * |
||
19 | * @param Collection $collection |
||
20 | */ |
||
21 | public function __construct(Collection $collection) |
||
25 | |||
26 | /** |
||
27 | * Return the current element |
||
28 | * |
||
29 | * @link http://php.net/manual/en/iterator.current.php |
||
30 | * @return Model |
||
31 | * @throws \Exception |
||
32 | */ |
||
33 | public function current() |
||
37 | |||
38 | /** |
||
39 | * Move forward to next element |
||
40 | * |
||
41 | * @link http://php.net/manual/en/iterator.next.php |
||
42 | * @return Model |
||
43 | */ |
||
44 | public function next() |
||
48 | |||
49 | /** |
||
50 | * Checks if current position is valid |
||
51 | * |
||
52 | * @link http://php.net/manual/en/iterator.valid.php |
||
53 | * @return boolean |
||
54 | */ |
||
55 | public function valid() |
||
61 | |||
62 | /** |
||
63 | * Return the key of the current element |
||
64 | * |
||
65 | * @link http://php.net/manual/en/iterator.key.php |
||
66 | * @return integer |
||
67 | */ |
||
68 | public function key() |
||
72 | |||
73 | /** |
||
74 | * Rewind the Iterator to the first element |
||
75 | * |
||
76 | * @link http://php.net/manual/en/iterator.rewind.php |
||
77 | * @return void |
||
78 | * @throws \Exception |
||
79 | */ |
||
80 | public function rewind() |
||
86 | } |