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