Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 4488af6

Browse files
author
Mateusz Gostański
committed
Added parsing datetime strings to Carbon objects in StraightKeyParser
1 parent 364a0f9 commit 4488af6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Data/StraightKeyParser.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Grixu\ApiClient\Data;
44

55
use Grixu\ApiClient\Contracts\ResponseParser;
6+
use Illuminate\Support\Carbon;
67
use Illuminate\Support\Collection;
78

89
class StraightKeyParser implements ResponseParser
@@ -19,6 +20,12 @@ public function parse(Collection $inputData): Collection
1920
continue;
2021
}
2122

23+
foreach ($data as $key => $value) {
24+
if (Carbon::createFromTimeString($value) == true) {
25+
$data[$key] = Carbon::createFromTimeString($value);
26+
}
27+
}
28+
2229
$dto = new $this->dtoClass($data);
2330

2431
$parsed->push($dto);

0 commit comments

Comments
 (0)