Total Complexity | 16 |
Total Lines | 54 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
6 | class MultipleArrayIterator implements Iterator |
||
7 | { |
||
8 | protected $arrays; |
||
9 | protected $active; |
||
10 | |||
11 | public function __construct() |
||
12 | { |
||
13 | $args = func_get_args(); |
||
14 | |||
15 | $this->arrays = array(); |
||
16 | foreach ($args as $arg) { |
||
17 | if (is_array($arg) && count($arg)) { |
||
18 | $this->arrays[] = $arg; |
||
19 | } |
||
20 | } |
||
21 | |||
22 | $this->rewind(); |
||
23 | } |
||
24 | |||
25 | public function rewind() |
||
26 | { |
||
27 | $this->active = $this->arrays; |
||
28 | if ($this->active) { |
||
29 | reset($this->active[0]); |
||
30 | } |
||
31 | } |
||
32 | |||
33 | public function current() |
||
34 | { |
||
35 | return $this->active ? current($this->active[0]) : false; |
||
36 | } |
||
37 | |||
38 | public function key() |
||
41 | } |
||
42 | |||
43 | public function next() |
||
44 | { |
||
45 | if (!$this->active) { |
||
46 | return; |
||
47 | } |
||
48 | |||
49 | if (next($this->active[0]) === false) { |
||
50 | array_shift($this->active); |
||
51 | if ($this->active) { |
||
52 | reset($this->active[0]); |
||
53 | } |
||
54 | } |
||
55 | } |
||
56 | |||
57 | public function valid() |
||
60 | } |
||
61 | } |
||
62 |