Conditions | 7 |
Paths | 5 |
Total Lines | 26 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 7 |
Changes | 0 |
1 | <?php |
||
23 | 1 | public function getRecurrences(DateTimeInterface $from, DateTimeInterface $to, $inc = true) |
|
24 | { |
||
25 | 1 | $rRule = CronExpression::factory($this->getRrule()); |
|
26 | 1 | $result = []; |
|
27 | |||
28 | 1 | if ($to->getTimestamp() < $this->getStartDate()->getTimestamp()) { |
|
29 | 1 | return $result; |
|
30 | } |
||
31 | |||
32 | 1 | if ($from->getTimestamp() < $this->getStartDate()->getTimestamp()) { |
|
33 | 1 | $from = clone $this->getStartDate(); |
|
34 | } |
||
35 | |||
36 | 1 | $firstIteration = true; |
|
37 | |||
38 | do { |
||
39 | 1 | $nextRunDate = $rRule->getNextRunDate($from, 0, $firstIteration && $inc); |
|
40 | 1 | if ($nextRunDate->getTimestamp() < ($to->getTimestamp() + (int) $inc) && $from->getTimestamp() <= $nextRunDate->getTimestamp()) { |
|
41 | 1 | $result[] = $nextRunDate; |
|
42 | } |
||
43 | 1 | $firstIteration = false; |
|
44 | 1 | $from = $nextRunDate; |
|
45 | 1 | } while ($nextRunDate->getTimestamp() < ($to->getTimestamp() + (int) $inc)); |
|
46 | |||
47 | 1 | return $result; |
|
48 | } |
||
49 | } |