|
2 | 2 |
|
3 | 3 | namespace Sabre\VObject\Recur;
|
4 | 4 |
|
5 |
| -use DateTimeImmutable; |
6 | 5 | use DateTimeInterface;
|
7 | 6 | use Iterator;
|
8 | 7 | use Sabre\VObject\DateTimeParser;
|
@@ -85,26 +84,27 @@ public function rewind()
|
85 | 84 |
|
86 | 85 | /**
|
87 | 86 | * Goes on to the next iteration.
|
| 87 | + * |
88 | 88 | * @param int $amount
|
89 | 89 | */
|
90 | 90 | public function next($amount = 1)
|
91 | 91 | {
|
92 | 92 | // Otherwise, we find the next event in the normal RRULE
|
93 | 93 | // sequence.
|
94 | 94 | switch ($this->frequency) {
|
95 |
| - case 'hourly' : |
| 95 | + case 'hourly': |
96 | 96 | $this->nextHourly($amount);
|
97 | 97 | break;
|
98 |
| - case 'daily' : |
| 98 | + case 'daily': |
99 | 99 | $this->nextDaily($amount);
|
100 | 100 | break;
|
101 |
| - case 'weekly' : |
| 101 | + case 'weekly': |
102 | 102 | $this->nextWeekly($amount);
|
103 | 103 | break;
|
104 |
| - case 'monthly' : |
| 104 | + case 'monthly': |
105 | 105 | $this->nextMonthly($amount);
|
106 | 106 | break;
|
107 |
| - case 'yearly' : |
| 107 | + case 'yearly': |
108 | 108 | $this->nextYearly($amount);
|
109 | 109 | break;
|
110 | 110 | }
|
@@ -135,19 +135,19 @@ public function fastForward(DateTimeInterface $dt)
|
135 | 135 | do {
|
136 | 136 | $diff = $this->currentDate->diff($dt);
|
137 | 137 | switch ($this->frequency) {
|
138 |
| - case 'hourly' : |
| 138 | + case 'hourly': |
139 | 139 | $i = $diff->days * 24;
|
140 | 140 | break;
|
141 |
| - case 'daily' : |
| 141 | + case 'daily': |
142 | 142 | $i = $diff->days;
|
143 | 143 | break;
|
144 |
| - case 'weekly' : |
| 144 | + case 'weekly': |
145 | 145 | $i = $diff->days / 7;
|
146 | 146 | break;
|
147 |
| - case 'monthly' : |
| 147 | + case 'monthly': |
148 | 148 | $i = $diff->days / 30;
|
149 | 149 | break;
|
150 |
| - case 'yearly' : |
| 150 | + case 'yearly': |
151 | 151 | $i = $diff->days / 365;
|
152 | 152 | break;
|
153 | 153 | }
|
@@ -355,6 +355,7 @@ protected function nextDaily($amount = 1)
|
355 | 355 | {
|
356 | 356 | if (!$this->byHour && !$this->byDay) {
|
357 | 357 | $this->currentDate = $this->currentDate->modify('+'.$amount * $this->interval.' days');
|
| 358 | + |
358 | 359 | return;
|
359 | 360 | }
|
360 | 361 |
|
@@ -403,10 +404,12 @@ protected function nextDaily($amount = 1)
|
403 | 404 | /**
|
404 | 405 | * Does the processing for advancing the iterator for weekly frequency.
|
405 | 406 | */
|
406 |
| - protected function nextWeekly($amount = 1) { |
| 407 | + protected function nextWeekly($amount = 1) |
| 408 | + { |
407 | 409 |
|
408 | 410 | 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 | + |
410 | 413 | return;
|
411 | 414 | }
|
412 | 415 |
|
@@ -435,7 +438,7 @@ protected function nextWeekly($amount = 1) {
|
435 | 438 | $currentHour = (int) $this->currentDate->format('G');
|
436 | 439 |
|
437 | 440 | // 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)) { |
439 | 442 | $this->currentDate = $this->currentDate->modify('+'.(($amount * $this->interval) - 1).' weeks');
|
440 | 443 | $amount = 1;
|
441 | 444 | // We need to go to the first day of this week, but only if we
|
|
0 commit comments