DateRecurHelper.php in Recurring Dates Field 3.x
File
src/DateRecurHelper.php
View source
<?php
declare (strict_types=1);
namespace Drupal\date_recur;
use Drupal\Component\Assertion\Inspector;
use Drupal\date_recur\Rl\RlHelper;
final class DateRecurHelper implements DateRecurHelperInterface {
protected $dateRecurHelper;
public function __construct(DateRecurHelperInterface $dateRecurHelper) {
$this->dateRecurHelper = $dateRecurHelper;
}
public static function create(string $string, \DateTimeInterface $dtStart, \DateTimeInterface $dtStartEnd = NULL) {
$dateRecurHelper = RlHelper::createInstance($string, $dtStart, $dtStartEnd);
return new static($dateRecurHelper);
}
public static function createInstance(string $string, \DateTimeInterface $dtStart, ?\DateTimeInterface $dtStartEnd = NULL) : DateRecurHelperInterface {
throw new \LogicException('Create instance must not be called on this helper.');
}
public function getRules() : array {
$rules = $this->dateRecurHelper
->getRules();
assert(is_array($rules));
assert(Inspector::assertAllObjects($rules, DateRecurRuleInterface::class));
return $rules;
}
public function isInfinite() : bool {
return $this->dateRecurHelper
->isInfinite();
}
public function generateOccurrences(?\DateTimeInterface $rangeStart = NULL, ?\DateTimeInterface $rangeEnd = NULL) : \Generator {
return $this->dateRecurHelper
->generateOccurrences($rangeStart, $rangeEnd);
}
public function getOccurrences(\DateTimeInterface $rangeStart = NULL, ?\DateTimeInterface $rangeEnd = NULL, ?int $limit = NULL) : array {
return $this->dateRecurHelper
->getOccurrences($rangeStart, $rangeEnd, $limit);
}
public function getExcluded() : array {
$exDates = $this->dateRecurHelper
->getExcluded();
assert(Inspector::assertAllObjects($exDates, \DateTimeInterface::class));
return $exDates;
}
public function current() : DateRange {
return $this->dateRecurHelper
->current();
}
public function next() : void {
$this->dateRecurHelper
->next();
}
public function key() : ?int {
return $this->dateRecurHelper
->key();
}
public function valid() : bool {
return $this->dateRecurHelper
->valid();
}
public function rewind() : void {
$this->dateRecurHelper
->rewind();
}
}