/** * Creates a time interval. * * @param Time $start * @param Time $end * * @throws \InvalidArgumentException If the opening time is not earlier than closing time */ public function __construct(Time $start, Time $end) { $this->start = $start; $this->end = $end; if ($start->isAfterOrEqual($end)) { throw new \InvalidArgumentException(sprintf('The opening time "%s" must be before the closing time "%s".', $start->toString(), $end->toString())); } }
/** * {@inheritdoc} */ public function contains(Time $time) { return $this->start->isBeforeOrEqual($time) && $this->end->isAfterOrEqual($time); }