/** * Checks if ranges are equal. * * @param DateRange $range The range to compare to. * * @return boolean * * @since 2.0.0 */ public function equals(DateRange $range) { return $this->range->equals($range->range); }
/** * Compares two objects. * * @param DateTimeRange $a Base object. * @param DateTimeRange $b Object to compare to. * * @return integer * * @since 2.0.0 * @throws \InvalidArgumentException */ private static function compare(DateTimeRange $a, DateTimeRange $b) { if (!$a->interval->equals($b->interval)) { throw new \InvalidArgumentException('Intervals of ranges are not equal.'); } if ($a->equals($b)) { return 0; } if ($a->start()->isAfter($b->start())) { return 1; } if ($a->start()->isBefore($b->start()) || $a->end()->isBefore($b->end())) { return -1; } return 1; }