public function valid() { if ($this->cache === true) { // check to see if the current position has already been stored if (!empty($this->results[$this->position])) { return isset($this->results[$this->position]); } elseif ($next_date = parent::next()) { // if it hasn't been found, check to see if there are more // dates $this->results[] = $next_date; return isset($next_date); } } else { // check to see if there is another result and set that as the // result if ($next_date = parent::next()) { $this->result = $next_date; return isset($this->result); } } // end the foreach loop when all options are exhausted return false; }