/** * Returns the highest LocalDateTime among the given values. * * @param LocalDateTime ... $times The LocalDateTime objects to compare. * * @return LocalDateTime The latest LocalDateTime object. * * @throws DateTimeException If the array is empty. */ public static function maxOf(LocalDateTime ...$times) { if (!$times) { throw new DateTimeException(__METHOD__ . ' does not accept less than 1 parameter.'); } $max = LocalDateTime::min(); foreach ($times as $time) { if ($time->isAfter($max)) { $max = $time; } } return $max; }
public function testMin() { $this->assertLocalDateTimeIs(Year::MIN_VALUE, 1, 1, 0, 0, 0, 0, LocalDateTime::min()); }