/** * Returns the smallest LocalTime among the given values. * * @param LocalTime ... $times The LocalTime objects to compare. * * @return LocalTime The earliest LocalTime object. * * @throws DateTimeException If the array is empty. */ public static function minOf(LocalTime ...$times) { if (!$times) { throw new DateTimeException(__METHOD__ . ' does not accept less than 1 parameter.'); } $min = LocalTime::max(); foreach ($times 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->assertLocalTimeIs(23, 59, 59, 999999999, LocalTime::max()); }