Skip to content

Commit 568e727

Browse files
committed
Add testcases
1 parent a00a460 commit 568e727

File tree

3 files changed

+449
-15
lines changed

3 files changed

+449
-15
lines changed

lib/Recur/RRuleIterator.php

+17-14
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Sabre\VObject\Recur;
44

5-
use DateTimeImmutable;
65
use DateTimeInterface;
76
use Iterator;
87
use Sabre\VObject\DateTimeParser;
@@ -85,26 +84,27 @@ public function rewind()
8584

8685
/**
8786
* Goes on to the next iteration.
87+
*
8888
* @param int $amount
8989
*/
9090
public function next($amount = 1)
9191
{
9292
// Otherwise, we find the next event in the normal RRULE
9393
// sequence.
9494
switch ($this->frequency) {
95-
case 'hourly' :
95+
case 'hourly':
9696
$this->nextHourly($amount);
9797
break;
98-
case 'daily' :
98+
case 'daily':
9999
$this->nextDaily($amount);
100100
break;
101-
case 'weekly' :
101+
case 'weekly':
102102
$this->nextWeekly($amount);
103103
break;
104-
case 'monthly' :
104+
case 'monthly':
105105
$this->nextMonthly($amount);
106106
break;
107-
case 'yearly' :
107+
case 'yearly':
108108
$this->nextYearly($amount);
109109
break;
110110
}
@@ -135,19 +135,19 @@ public function fastForward(DateTimeInterface $dt)
135135
do {
136136
$diff = $this->currentDate->diff($dt);
137137
switch ($this->frequency) {
138-
case 'hourly' :
138+
case 'hourly':
139139
$i = $diff->days * 24;
140140
break;
141-
case 'daily' :
141+
case 'daily':
142142
$i = $diff->days;
143143
break;
144-
case 'weekly' :
144+
case 'weekly':
145145
$i = $diff->days / 7;
146146
break;
147-
case 'monthly' :
147+
case 'monthly':
148148
$i = $diff->days / 30;
149149
break;
150-
case 'yearly' :
150+
case 'yearly':
151151
$i = $diff->days / 365;
152152
break;
153153
}
@@ -355,6 +355,7 @@ protected function nextDaily($amount = 1)
355355
{
356356
if (!$this->byHour && !$this->byDay) {
357357
$this->currentDate = $this->currentDate->modify('+'.$amount * $this->interval.' days');
358+
358359
return;
359360
}
360361

@@ -403,10 +404,12 @@ protected function nextDaily($amount = 1)
403404
/**
404405
* Does the processing for advancing the iterator for weekly frequency.
405406
*/
406-
protected function nextWeekly($amount = 1) {
407+
protected function nextWeekly($amount = 1)
408+
{
407409

408410
if (!$this->byHour && !$this->byDay) {
409-
$this->currentDate = $this->currentDate->modify('+' .($amount * $this->interval).' weeks');
411+
$this->currentDate = $this->currentDate->modify('+'.($amount * $this->interval).' weeks');
412+
410413
return;
411414
}
412415

@@ -435,7 +438,7 @@ protected function nextWeekly($amount = 1) {
435438
$currentHour = (int) $this->currentDate->format('G');
436439

437440
// We need to roll over to the next week
438-
if ($currentDay === $firstDay && (!$this->byHour || $currentHour == '0')) {
441+
if ($currentDay === $firstDay && (!$this->byHour || '0' == $currentHour)) {
439442
$this->currentDate = $this->currentDate->modify('+'.(($amount * $this->interval) - 1).' weeks');
440443
$amount = 1;
441444
// We need to go to the first day of this week, but only if we

0 commit comments

Comments
 (0)