From 5ed8a35420ce4fc80b2952e5b4e377d834409141 Mon Sep 17 00:00:00 2001 From: Vlada Hejda Date: Tue, 20 Jun 2023 21:52:24 +0200 Subject: [PATCH] NightInterval::containsValue() fix --- src/Time/Interval/NightInterval.php | 4 ++++ tests/src/Time/Interval/NightInterval.phpt | 1 + 2 files changed, 5 insertions(+) diff --git a/src/Time/Interval/NightInterval.php b/src/Time/Interval/NightInterval.php index a49e6596..0370007f 100644 --- a/src/Time/Interval/NightInterval.php +++ b/src/Time/Interval/NightInterval.php @@ -311,6 +311,10 @@ public function compareIntersects(IntersectComparable $other): int */ public function containsValue($date): bool { + if ($this->isEmpty()) { + return false; + } + if (!$date instanceof Date) { $date = Date::createFromDateTimeInterface($date); } diff --git a/tests/src/Time/Interval/NightInterval.phpt b/tests/src/Time/Interval/NightInterval.phpt index b3f7dabd..94316a03 100644 --- a/tests/src/Time/Interval/NightInterval.phpt +++ b/tests/src/Time/Interval/NightInterval.phpt @@ -150,6 +150,7 @@ Assert::false($interval->containsValue($d(21))); Assert::false($interval->containsValue($d(5))); Assert::false($interval->containsValue($d(25))); Assert::true($interval->containsValue(new DateTimeImmutable('2000-01-15'))); +Assert::false($empty->containsValue($d(10))); contains: