diff options
Diffstat (limited to 'vendor/sabre/vobject/lib/Recur/RDateIterator.php')
-rw-r--r-- | vendor/sabre/vobject/lib/Recur/RDateIterator.php | 73 |
1 files changed, 43 insertions, 30 deletions
diff --git a/vendor/sabre/vobject/lib/Recur/RDateIterator.php b/vendor/sabre/vobject/lib/Recur/RDateIterator.php index 013694b95..f44960e12 100644 --- a/vendor/sabre/vobject/lib/Recur/RDateIterator.php +++ b/vendor/sabre/vobject/lib/Recur/RDateIterator.php @@ -19,30 +19,29 @@ use Sabre\VObject\DateTimeParser; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class RDateIterator implements Iterator -{ +class RDateIterator implements Iterator { + /** * Creates the Iterator. * - * @param string|array $rrule + * @param string|array $rrule * @param DateTimeInterface $start */ - public function __construct($rrule, DateTimeInterface $start) - { + function __construct($rrule, DateTimeInterface $start) { + $this->startDate = $start; $this->parseRDate($rrule); $this->currentDate = clone $this->startDate; + } /* Implementation of the Iterator interface {{{ */ - public function current() - { - if (!$this->valid()) { - return; - } + function current() { + if (!$this->valid()) return; return clone $this->currentDate; + } /** @@ -50,9 +49,10 @@ class RDateIterator implements Iterator * * @return int */ - public function key() - { + function key() { + return $this->counter; + } /** @@ -61,35 +61,40 @@ class RDateIterator implements Iterator * * @return bool */ - public function valid() - { - return $this->counter <= count($this->dates); + function valid() { + + return ($this->counter <= count($this->dates)); + } /** * Resets the iterator. + * + * @return void */ - public function rewind() - { + function rewind() { + $this->currentDate = clone $this->startDate; $this->counter = 0; + } /** * Goes on to the next iteration. + * + * @return void */ - public function next() - { - ++$this->counter; - if (!$this->valid()) { - return; - } + function next() { + + $this->counter++; + if (!$this->valid()) return; $this->currentDate = DateTimeParser::parse( $this->dates[$this->counter - 1], $this->startDate->getTimezone() ); + } /* End of Iterator implementation }}} */ @@ -99,9 +104,10 @@ class RDateIterator implements Iterator * * @return bool */ - public function isInfinite() - { + function isInfinite() { + return false; + } /** @@ -109,12 +115,15 @@ class RDateIterator implements Iterator * specified date. * * @param DateTimeInterface $dt + * + * @return void */ - public function fastForward(DateTimeInterface $dt) - { + function fastForward(DateTimeInterface $dt) { + while ($this->valid() && $this->currentDate < $dt) { $this->next(); } + } /** @@ -150,20 +159,24 @@ class RDateIterator implements Iterator * class with all the values. * * @param string|array $rrule + * + * @return void */ - protected function parseRDate($rdate) - { + protected function parseRDate($rdate) { + if (is_string($rdate)) { $rdate = explode(',', $rdate); } $this->dates = $rdate; + } /** - * Array with the RRULE dates. + * Array with the RRULE dates * * @var array */ protected $dates = []; + } |