Skip to content

Commit 8eaabc0

Browse files
committed
Add testcases
1 parent a00a460 commit 8eaabc0

File tree

3 files changed

+448
-17
lines changed

3 files changed

+448
-17
lines changed

lib/Recur/RRuleIterator.php

+17-16
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

@@ -384,7 +385,6 @@ protected function nextDaily($amount = 1)
384385
$amount = 1;
385386
}
386387

387-
388388
// Current month of the year
389389
$currentMonth = $this->currentDate->format('n');
390390

@@ -403,10 +403,11 @@ protected function nextDaily($amount = 1)
403403
/**
404404
* Does the processing for advancing the iterator for weekly frequency.
405405
*/
406-
protected function nextWeekly($amount = 1) {
407-
406+
protected function nextWeekly($amount = 1)
407+
{
408408
if (!$this->byHour && !$this->byDay) {
409-
$this->currentDate = $this->currentDate->modify('+' .($amount * $this->interval).' weeks');
409+
$this->currentDate = $this->currentDate->modify('+'.($amount * $this->interval).' weeks');
410+
410411
return;
411412
}
412413

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

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

0 commit comments

Comments
 (0)