Conditions | 4 |
Paths | 8 |
Total Lines | 19 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | public function provide(Recurrence $recurrence): array |
||
13 | { |
||
14 | 1 | $periodEndAt = ($recurrence->hasPeriodEndAt()) ? $recurrence->getPeriodEndAt() : $this->estimatePeriodEndAt($recurrence); |
|
15 | |||
16 | 1 | $recurrences = []; |
|
17 | |||
18 | 1 | $date = clone $recurrence->getPeriodStartAt(); |
|
19 | |||
20 | 1 | while ($date < $periodEndAt) { |
|
21 | 1 | $recurrences[] = clone $date; |
|
22 | 1 | $date->modify('last day of next month'); |
|
23 | } |
||
24 | |||
25 | // When having count option, return only amount of recurrences requested |
||
26 | 1 | if ($recurrence->hasCount()) { |
|
27 | 1 | return array_slice($recurrences, 0, $recurrence->getCount()); |
|
28 | } |
||
29 | |||
30 | 1 | return $recurrences; |
|
31 | } |
||
33 |