|
@@ 27-39 (lines=13) @@
|
| 24 |
|
* @throws |
| 25 |
|
* @return DateTimeInterface[] |
| 26 |
|
*/ |
| 27 |
|
public function getRecurrences(DateTimeInterface $from, DateTimeInterface $to, $inc = true) |
| 28 |
|
{ |
| 29 |
|
$rRule = new RecurrRule($this->getRrule(), $this->getStartDate()); |
| 30 |
|
$rRuleTransformer = new ArrayTransformer(); |
| 31 |
|
$constraint = new BetweenConstraint($from, $to, $inc); |
| 32 |
|
$recurrenceCollection = $rRuleTransformer->transform($rRule, $constraint); |
| 33 |
|
$result = []; |
| 34 |
|
/** @var Recurrence $recurrence */ |
| 35 |
|
foreach ($recurrenceCollection as $recurrence) { |
| 36 |
|
$result[] = $recurrence->getStart(); |
| 37 |
|
} |
| 38 |
|
return $result; |
| 39 |
|
} |
| 40 |
|
|
| 41 |
|
/** |
| 42 |
|
* @param DateTimeInterface $from |
|
@@ 47-60 (lines=14) @@
|
| 44 |
|
* @return DateTimeInterface|null date of the next recurrence or null of no more recurrences scheduled. |
| 45 |
|
* @throws |
| 46 |
|
*/ |
| 47 |
|
public function getNextRecurrence(DateTimeInterface $from, $inc = true) |
| 48 |
|
{ |
| 49 |
|
$rRule = new RecurrRule($this->getRrule(), $this->getStartDate()); |
| 50 |
|
$rRuleTransformer = new ArrayTransformer(); |
| 51 |
|
$constraint = new AfterConstraint($from, $inc); |
| 52 |
|
$recurrenceCollection = $rRuleTransformer->transform($rRule, $constraint); |
| 53 |
|
$result = null; |
| 54 |
|
/** @var Recurrence $recurrence */ |
| 55 |
|
foreach ($recurrenceCollection as $recurrence) { |
| 56 |
|
$result = $recurrence->getStart(); |
| 57 |
|
break; |
| 58 |
|
} |
| 59 |
|
return $result; |
| 60 |
|
} |
| 61 |
|
} |