_sets[] = $s; } $this->_max = count($this->_sets) - 1; $this->_break = empty($this->_sets); return; } /** * Get the current value. * * @return array */ public function current() { return $this->_current; } /** * Prepare the current value. * * @return void */ protected function _current() { $this->_current = []; foreach ($this->_sets as $set) { $this->_current[] = $set->current(); } return; } /** * Get the current key. * * @return int */ public function key() { return $this->_key; } /** * Advance the internal collection pointer, and return the current value. * * @return array */ public function next() { for ($i = 0; $i <= $this->_max; ++$i) { $this->_sets[$i]->next(); if (false !== $this->_sets[$i]->valid()) { break; } $this->_sets[$i]->rewind(); if ($i === $this->_max) { $this->_break = true; break; } } ++$this->_key; $this->_current(); return $this->current(); } /** * Rewind the internal collection pointer, and return the first collection. * * @return array */ public function rewind() { $this->_break = empty($this->_sets); $this->_key = 0; foreach ($this->_sets as $set) { $set->rewind(); } $this->_current(); return $this->current(); } /** * Check if there is a current element after calls to the rewind() or the * next() methods. * * @return bool */ public function valid() { return false === $this->_break; } }