Example #1
0
 /**
  * @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 $start
  * @param CalendarDate|null $end
  * @param Duration $duration
  * @param int|null $recurrence
  *
  * @throws InvalidArgumentException
  */
 private function __construct(CalendarDate $start, CalendarDate $end = null, Duration $duration, $recurrence = null)
 {
     if ($recurrence !== null && !is_int($recurrence)) {
         throw new InvalidArgumentException(sprintf('%s is not integer', '$recurrence'));
     }
     if ($end && $end->earlierThan($start)) {
         throw new InvalidArgumentException(sprintf('%s must be later then %s', '$end', '$start'));
     }
     $this->start = $start;
     $this->end = $end;
     $this->duration = $duration;
     $this->recurrence = $recurrence;
 }