Skip to content

Commit 87b7fa7

Browse files
authored
Addition to timestamp range with quotes (#32)
* added quotes to stringify * remove autoformat * stringify * removed unused use * removed unused use * regex fix * replace quotes instead of overriding regex * fix test
1 parent 00a57d8 commit 87b7fa7

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/Casts/TimestampRangeCast.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,15 @@ public function getRangeInstance(array $matches): TimestampRange
1414
{
1515
return new TimestampRange($matches[2], $matches[3], $matches[1], $matches[4]);
1616
}
17+
18+
/**
19+
* @param $value
20+
* @return array
21+
*/
22+
protected function parseStringRange($value): array
23+
{
24+
$withoutQuotes = str_replace('"', '', $value);
25+
26+
return parent::parseStringRange($withoutQuotes);
27+
}
1728
}

tests/Feature/RangesCastingTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public function it_does_not_detect_changes_when_updating_with_same_timestamp_ran
5757
);
5858

5959
$this->assertEmpty($model->getChanges());
60+
$this->assertEquals((string) $model->getOriginal('timestamp_range'), (string) $model->timestamp_range);
6061
}
6162

6263
/** @test */

0 commit comments

Comments
 (0)