Repository: spatie/opening-hours (php)

Issue:
setDateTimeClass is missing on OpeningHours::class
When creating the OpeningHours class using the static method createAndMergeOverlappingRanges, you are unable to set the DateTimeClass for that instance. You should be able to pass it via createAndMergeOverlappingRanges method, or a setDateTimeClass method must be available like in version 2.41.0. 

Pull request:
Allow 'dateTimeClass' in mergeOverlappingRanges and createAndMerge*
Allow `'dateTimeClass'` in `mergeOverlappingRanges` and `createAndMergeOverlappingRanges`

Fix #266

Patch:
diff --git a/src/OpeningHours.php b/src/OpeningHours.php
index bbedb18..7078dd1 100644
--- a/src/OpeningHours.php
+++ b/src/OpeningHours.php
@@ -147,7 +147,7 @@ class OpeningHours
      * @param  array  $excludedKeys  keys to ignore from parsing
      * @return array
      */
-    public static function mergeOverlappingRanges(array $data, array $excludedKeys = ['data', 'filters', 'overflow']): array
+    public static function mergeOverlappingRanges(array $data, array $excludedKeys = ['data', 'dateTimeClass', 'filters', 'overflow']): array
     {
         $result = [];
         $ranges = [];


Test patch:
diff --git a/tests/OpeningHoursFillTest.php b/tests/OpeningHoursFillTest.php
index b7f062c..2d994e1 100644
--- a/tests/OpeningHoursFillTest.php
+++ b/tests/OpeningHoursFillTest.php
@@ -314,6 +314,32 @@ class OpeningHoursFillTest extends TestCase
         ], $dump['tuesday']);
     }
 
+    #[Test]
+    public function it_should_merge_ranges_and_keep_date_time_class()
+    {
+        $hours = OpeningHours::createAndMergeOverlappingRanges([
+            'dateTimeClass' => DateTimeImmutable::class,
+            'monday' => [
+                '08:00-12:00',
+                '08:00-12:00',
+                '11:30-13:30',
+                '13:00-18:00',
+            ],
+            'tuesday' => [
+                '08:00-12:00',
+                '11:30-13:30',
+                '15:00-18:00',
+                '16:00-17:00',
+                '19:00-20:00',
+                '20:00-21:00',
+            ],
+        ]);
+        $date = $hours->nextOpen(new DateTimeImmutable('2018-12-03'));
+        $this->assertInstanceOf(DateTimeImmutable::class, $date);
+
+        $this->assertSame('2018-12-03 08:00', $date->format('Y-m-d H:i'));
+    }
+
     #[Test]
     public function it_should_merge_ranges_including_explicit_24_00()
     {