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, 30 insertions, 43 deletions
diff --git a/vendor/sabre/vobject/lib/Recur/RDateIterator.php b/vendor/sabre/vobject/lib/Recur/RDateIterator.php index f44960e12..013694b95 100644 --- a/vendor/sabre/vobject/lib/Recur/RDateIterator.php +++ b/vendor/sabre/vobject/lib/Recur/RDateIterator.php @@ -19,29 +19,30 @@ 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 */ - function __construct($rrule, DateTimeInterface $start) { - + public function __construct($rrule, DateTimeInterface $start) + { $this->startDate = $start; $this->parseRDate($rrule); $this->currentDate = clone $this->startDate; - } /* Implementation of the Iterator interface {{{ */ - function current() { + public function current() + { + if (!$this->valid()) { + return; + } - if (!$this->valid()) return; return clone $this->currentDate; - } /** @@ -49,10 +50,9 @@ class RDateIterator implements Iterator { * * @return int */ - function key() { - + public function key() + { return $this->counter; - } /** @@ -61,40 +61,35 @@ class RDateIterator implements Iterator { * * @return bool */ - function valid() { - - return ($this->counter <= count($this->dates)); - + public function valid() + { + return $this->counter <= count($this->dates); } /** * Resets the iterator. - * - * @return void */ - function rewind() { - + public function rewind() + { $this->currentDate = clone $this->startDate; $this->counter = 0; - } /** * Goes on to the next iteration. - * - * @return void */ - function next() { - - $this->counter++; - if (!$this->valid()) return; + public function next() + { + ++$this->counter; + if (!$this->valid()) { + return; + } $this->currentDate = DateTimeParser::parse( $this->dates[$this->counter - 1], $this->startDate->getTimezone() ); - } /* End of Iterator implementation }}} */ @@ -104,10 +99,9 @@ class RDateIterator implements Iterator { * * @return bool */ - function isInfinite() { - + public function isInfinite() + { return false; - } /** @@ -115,15 +109,12 @@ class RDateIterator implements Iterator { * specified date. * * @param DateTimeInterface $dt - * - * @return void */ - function fastForward(DateTimeInterface $dt) { - + public function fastForward(DateTimeInterface $dt) + { while ($this->valid() && $this->currentDate < $dt) { $this->next(); } - } /** @@ -159,24 +150,20 @@ 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 = []; - } |