/** * @param CalendarDate|Object $start * @param CalendarDate|HasClassName $end */ protected function __construct(CalendarDate $start, CalendarDate $end) { if (!$end->sameTypeAs($start)) { throw new NotMatchTypeException($end); } if ($end->earlierThan($start)) { throw new InvalidArgumentException(sprintf('%s must be later then %s', '$end', '$start')); } $this->start = $start; $this->end = $end; }
/** * @param CalendarDate $end * @param Duration $duration * @param int|null $recurrence * * @return static */ public static function createFromEndDuration(CalendarDate $end, Duration $duration, $recurrence = null) { return static::create($end->sub($duration), null, $duration, $recurrence); }