/** * Returns the smallest LocalDate among the given values. * * @param LocalDate ... $dates The LocalDate objects to compare. * * @return LocalDate The earliest LocalDate object. * * @throws DateTimeException If the array is empty. */ public static function minOf(LocalDate ...$dates) { if (!$dates) { throw new DateTimeException(__METHOD__ . ' does not accept less than 1 parameter.'); } $min = LocalDate::max(); foreach ($dates as $time) { if ($time->isBefore($min)) { $min = $time; } } return $min; }
/** * Returns the highest possible value for LocalDateTime. * * @return LocalDateTime */ public static function max() { return new LocalDateTime(LocalDate::max(), LocalTime::max()); }
public function testMax() { $this->assertLocalDateIs(Year::MAX_VALUE, 12, 31, LocalDate::max()); }