From c4d097179e700601e973e8eaf5372e3c112b1b70 Mon Sep 17 00:00:00 2001 From: KyleKatarn Date: Fri, 7 Dec 2018 16:54:38 +0100 Subject: [PATCH] Enable DateTimeImmutable --- src/OpeningHours.php | 4 ++-- src/Time.php | 2 +- tests/OpeningHoursTest.php | 14 -------------- tests/TimeTest.php | 2 -- 4 files changed, 3 insertions(+), 19 deletions(-) diff --git a/src/OpeningHours.php b/src/OpeningHours.php index 50aa9c3..90ce3ca 100644 --- a/src/OpeningHours.php +++ b/src/OpeningHours.php @@ -210,7 +210,7 @@ public function isClosed(): bool return $this->isClosedAt(new DateTime()); } - public function nextOpen(DateTimeInterface $dateTime): DateTime + public function nextOpen(DateTimeInterface $dateTime): DateTimeInterface { if (! ($dateTime instanceof DateTimeImmutable)) { $dateTime = clone $dateTime; @@ -235,7 +235,7 @@ public function nextOpen(DateTimeInterface $dateTime): DateTime return $dateTime; } - public function nextClose(DateTimeInterface $dateTime): DateTime + public function nextClose(DateTimeInterface $dateTime): DateTimeInterface { if (! ($dateTime instanceof DateTimeImmutable)) { $dateTime = clone $dateTime; diff --git a/src/Time.php b/src/Time.php index c50e12e..60cb76c 100644 --- a/src/Time.php +++ b/src/Time.php @@ -87,7 +87,7 @@ public function diff(self $time): \DateInterval return $this->toDateTime()->diff($time->toDateTime()); } - public function toDateTime(DateTime $date = null): DateTime + public function toDateTime(DateTimeInterface $date = null): DateTimeInterface { if (! $date) { $date = new DateTime('1970-01-01 00:00:00'); diff --git a/tests/OpeningHoursTest.php b/tests/OpeningHoursTest.php index 4c6c11d..c0ebea4 100644 --- a/tests/OpeningHoursTest.php +++ b/tests/OpeningHoursTest.php @@ -279,8 +279,6 @@ public function it_can_determine_next_open_hours_from_non_working_date_time() /** @test */ public function it_can_determine_next_open_hours_from_non_working_date_time_immutable() { - $this->markTestIncomplete('Not supported in v1.x'); - $openingHours = OpeningHours::create([ 'monday' => ['09:00-11:00', '13:00-19:00'], ]); @@ -313,8 +311,6 @@ public function it_can_determine_next_close_hours_from_non_working_date_time() /** @test */ public function it_can_determine_next_close_hours_from_non_working_date_time_immutable() { - $this->markTestIncomplete('Not supported in v1.x'); - $openingHours = OpeningHours::create([ 'monday' => ['09:00-11:00', '13:00-19:00'], ]); @@ -342,8 +338,6 @@ public function it_can_determine_next_open_hours_from_working_date_time() /** @test */ public function it_can_determine_next_open_hours_from_working_date_time_immutable() { - $this->markTestIncomplete('Not supported in v1.x'); - $openingHours = OpeningHours::create([ 'monday' => ['09:00-11:00', '13:00-19:00'], 'tuesday' => ['10:00-11:00', '14:00-19:00'], @@ -372,8 +366,6 @@ public function it_can_determine_next_close_hours_from_working_date_time() /** @test */ public function it_can_determine_next_close_hours_from_working_date_time_immutable() { - $this->markTestIncomplete('Not supported in v1.x'); - $openingHours = OpeningHours::create([ 'monday' => ['09:00-11:00', '13:00-19:00'], 'tuesday' => ['10:00-11:00', '14:00-19:00'], @@ -405,8 +397,6 @@ public function it_can_determine_next_open_hours_from_early_morning() /** @test */ public function it_can_determine_next_open_hours_from_early_morning_immutable() { - $this->markTestIncomplete('Not supported in v1.x'); - $openingHours = OpeningHours::create([ 'monday' => ['09:00-11:00', '13:00-19:00'], 'tuesday' => ['10:00-11:00', '14:00-19:00'], @@ -441,8 +431,6 @@ public function it_can_determine_next_close_hours_from_early_morning() /** @test */ public function it_can_determine_next_close_hours_from_early_morning_immutable() { - $this->markTestIncomplete('Not supported in v1.x'); - $openingHours = OpeningHours::create([ 'monday' => ['09:00-11:00', '13:00-19:00'], 'tuesday' => ['10:00-11:00', '14:00-19:00'], @@ -593,8 +581,6 @@ public function it_works_when_starting_at_midnight() /** @test */ public function it_works_when_starting_at_midnight_immutable() { - $this->markTestIncomplete('Not supported in v1.x'); - $openingHours = OpeningHours::create([ 'monday' => ['00:00-16:00'], ]); diff --git a/tests/TimeTest.php b/tests/TimeTest.php index 47ca758..d7e642f 100644 --- a/tests/TimeTest.php +++ b/tests/TimeTest.php @@ -121,8 +121,6 @@ public function it_should_not_mutate_passed_datetime() /** @test */ public function it_should_not_mutate_passed_datetime_immutable() { - $this->markTestIncomplete('Not supported in v1.x'); - $dateTime = new DateTimeImmutable('2016-09-27 12:00:00'); $time = Time::fromString('15:00'); $this->assertEquals('2016-09-27 15:00:00', $time->toDateTime($dateTime)->format('Y-m-d H:i:s'));