1 | <?php |
||
12 | class MapIterator implements Iterator, \JsonSerializable |
||
13 | { |
||
14 | /** |
||
15 | * @var Iterator |
||
16 | */ |
||
17 | protected $iterator; |
||
18 | |||
19 | /** |
||
20 | * @var callable Modifies the current item in iterator |
||
21 | */ |
||
22 | protected $callable; |
||
23 | |||
24 | /** |
||
25 | * @param $iterator Iterator|array |
||
26 | * @param $callable callable This can have two parameters |
||
27 | * |
||
28 | * @throws TDBMException |
||
29 | */ |
||
30 | public function __construct($iterator, callable $callable) |
||
53 | |||
54 | /** |
||
55 | * Alters the current item with $this->callable and returns a new item. |
||
56 | * Be careful with your types as we can't do static type checking here! |
||
57 | * |
||
58 | * @return mixed |
||
59 | */ |
||
60 | public function current() |
||
66 | |||
67 | public function next() |
||
71 | |||
72 | public function key() |
||
76 | |||
77 | public function valid() |
||
81 | |||
82 | public function rewind() |
||
86 | |||
87 | /** |
||
88 | * Casts the iterator to a PHP array. |
||
89 | * |
||
90 | * @return array |
||
91 | */ |
||
92 | public function toArray() |
||
96 | |||
97 | public function jsonSerialize() |
||
101 | } |
||
102 |