Skip to content

Commit 5ed8a35

Browse files
VladaHejdaparanoiq
authored andcommitted
NightInterval::containsValue() fix
1 parent a3e6315 commit 5ed8a35

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/Time/Interval/NightInterval.php

+4
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,10 @@ public function compareIntersects(IntersectComparable $other): int
311311
*/
312312
public function containsValue($date): bool
313313
{
314+
if ($this->isEmpty()) {
315+
return false;
316+
}
317+
314318
if (!$date instanceof Date) {
315319
$date = Date::createFromDateTimeInterface($date);
316320
}

tests/src/Time/Interval/NightInterval.phpt

+1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ Assert::false($interval->containsValue($d(21)));
150150
Assert::false($interval->containsValue($d(5)));
151151
Assert::false($interval->containsValue($d(25)));
152152
Assert::true($interval->containsValue(new DateTimeImmutable('2000-01-15')));
153+
Assert::false($empty->containsValue($d(10)));
153154

154155

155156
contains:

0 commit comments

Comments
 (0)