| 1 | <?php |
||
| 21 | class CollectionIterator extends ArrayIterator |
||
| 22 | { |
||
| 23 | /** |
||
| 24 | * Инстанс коллекции |
||
| 25 | * |
||
| 26 | * @var Collection |
||
| 27 | */ |
||
| 28 | private $collection; |
||
| 29 | |||
| 30 | |||
| 31 | /** |
||
| 32 | * Данные коллекции |
||
| 33 | * |
||
| 34 | * @var array |
||
| 35 | */ |
||
| 36 | private $data = array(); |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Конструктор итератора |
||
| 40 | * |
||
| 41 | * @param Collection $collection Коллекция |
||
| 42 | */ |
||
| 43 | public function __construct(Collection $collection) |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Return the current element |
||
| 50 | * |
||
| 51 | * @link http://php.net/manual/en/iterator.current.php |
||
| 52 | * @return Model |
||
| 53 | * @throws \Exception |
||
| 54 | */ |
||
| 55 | public function current() |
||
| 59 | |||
| 60 | /** |
||
| 61 | * Move forward to next element |
||
| 62 | * |
||
| 63 | * @link http://php.net/manual/en/iterator.next.php |
||
| 64 | * @return Model |
||
| 65 | */ |
||
| 66 | public function next() |
||
| 70 | |||
| 71 | /** |
||
| 72 | * Checks if current position is valid |
||
| 73 | * |
||
| 74 | * @link http://php.net/manual/en/iterator.valid.php |
||
| 75 | * @return boolean |
||
| 76 | */ |
||
| 77 | public function valid() |
||
| 83 | |||
| 84 | /** |
||
| 85 | * Return the key of the current element |
||
| 86 | * |
||
| 87 | * @link http://php.net/manual/en/iterator.key.php |
||
| 88 | * @return integer |
||
| 89 | */ |
||
| 90 | public function key() |
||
| 94 | |||
| 95 | /** |
||
| 96 | * Rewind the Iterator to the first element |
||
| 97 | * |
||
| 98 | * @link http://php.net/manual/en/iterator.rewind.php |
||
| 99 | * @return void |
||
| 100 | * @throws \Exception |
||
| 101 | */ |
||
| 102 | public function rewind() |
||
| 108 | } |