Skip to content

Commit 3f2279e

Browse files
committedDec 7, 2018
Add testcases
1 parent a00a460 commit 3f2279e

File tree

3 files changed

+448
-16
lines changed

3 files changed

+448
-16
lines changed
 

‎lib/Recur/RRuleIterator.php

+14-15
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;
@@ -92,19 +91,19 @@ public function next($amount = 1)
9291
// Otherwise, we find the next event in the normal RRULE
9392
// sequence.
9493
switch ($this->frequency) {
95-
case 'hourly' :
94+
case 'hourly':
9695
$this->nextHourly($amount);
9796
break;
98-
case 'daily' :
97+
case 'daily':
9998
$this->nextDaily($amount);
10099
break;
101-
case 'weekly' :
100+
case 'weekly':
102101
$this->nextWeekly($amount);
103102
break;
104-
case 'monthly' :
103+
case 'monthly':
105104
$this->nextMonthly($amount);
106105
break;
107-
case 'yearly' :
106+
case 'yearly':
108107
$this->nextYearly($amount);
109108
break;
110109
}
@@ -135,19 +134,19 @@ public function fastForward(DateTimeInterface $dt)
135134
do {
136135
$diff = $this->currentDate->diff($dt);
137136
switch ($this->frequency) {
138-
case 'hourly' :
137+
case 'hourly':
139138
$i = $diff->days * 24;
140139
break;
141-
case 'daily' :
140+
case 'daily':
142141
$i = $diff->days;
143142
break;
144-
case 'weekly' :
143+
case 'weekly':
145144
$i = $diff->days / 7;
146145
break;
147-
case 'monthly' :
146+
case 'monthly':
148147
$i = $diff->days / 30;
149148
break;
150-
case 'yearly' :
149+
case 'yearly':
151150
$i = $diff->days / 365;
152151
break;
153152
}
@@ -403,10 +402,11 @@ protected function nextDaily($amount = 1)
403402
/**
404403
* Does the processing for advancing the iterator for weekly frequency.
405404
*/
406-
protected function nextWeekly($amount = 1) {
405+
protected function nextWeekly($amount = 1)
406+
{
407407

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');
410410
return;
411411
}
412412

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

437437
// We need to roll over to the next week
438-
if ($currentDay === $firstDay && (!$this->byHour || $currentHour == '0')) {
438+
if ($currentDay === $firstDay && (!$this->byHour || '0' == $currentHour)) {
439439
$this->currentDate = $this->currentDate->modify('+'.(($amount * $this->interval) - 1).' weeks');
440440
$amount = 1;
441441
// We need to go to the first day of this week, but only if we
@@ -596,7 +596,6 @@ protected function nextYearly($amount = 1)
596596

597597
if (count($checkDates) > 0) {
598598
$this->currentDate = min($checkDates);
599-
600599
return;
601600
}
602601

0 commit comments

Comments
 (0)