Example #1
0
 /**
  * Evaluates the condition and returns its result, this controls
  * whether or not more results will be yielded.
  *
  * @return bool
  */
 public function valid()
 {
     if (!parent::valid()) {
         return false;
     }
     $current = $this->current();
     $key = $this->key();
     $condition = $this->_condition;
     return !$condition($current, $key, $this->_innerIterator);
 }
Example #2
0
 /**
  * Returns whether or not the iterator has more elements
  *
  * @return bool
  */
 public function valid()
 {
     if ($this->_buffer->offsetExists($this->_index)) {
         $current = $this->_buffer->offsetGet($this->_index);
         $this->_current = $current['value'];
         $this->_key = $current['key'];
         return true;
     }
     $valid = parent::valid();
     if ($valid) {
         $this->_current = parent::current();
         $this->_key = parent::key();
         $this->_buffer->push(['key' => $this->_key, 'value' => $this->_current]);
     }
     $this->_finished = !$valid;
     return $valid;
 }
 /**
  * Resets the collection pointer.
  *
  * @return void
  */
 public function rewind()
 {
     parent::rewind();
     $this->_values->rewind();
     $this->_validValues = $this->_values->valid();
 }