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 |
||
17 | public function provide(Recurrence $recurrence) |
||
18 | { |
||
19 | 1 | $periodEndAt = ($recurrence->hasPeriodEndAt())? $recurrence->getPeriodEndAt() : $this->estimatePeriodEndAt($recurrence) ; |
|
20 | |||
21 | 1 | $recurrences = []; |
|
22 | |||
23 | 1 | $date = clone $recurrence->getPeriodStartAt(); |
|
24 | |||
25 | 1 | while($date < $periodEndAt) { |
|
26 | 1 | $recurrences[] = clone $date; |
|
27 | 1 | $date->modify('last day of next month'); |
|
28 | } |
||
29 | |||
30 | // When having count option, return only amount of recurrences requested |
||
31 | 1 | if ($recurrence->hasCount()) { |
|
32 | 1 | return array_slice($recurrences, 0, $recurrence->getCount()); |
|
33 | } |
||
34 | |||
35 | 1 | return $recurrences; |
|
36 | } |
||
38 |