Skip to content

Commit 2e0c3aa

Browse files
committed
Fix type casting for null lat & lon location data
1 parent ea1f472 commit 2e0c3aa

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Dto/LocationDto.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,13 @@ public function setMessage(string $message): LocationDto
242242
*/
243243
public static function fromArray(array $locationData): self
244244
{
245+
$lat = $locationData['lat'] ?? null;
246+
$lon = $locationData['lon'] ?? null;
247+
245248
return new self(
246249
$locationData['status'],
247-
(string)$locationData['lat'] ?? null,
248-
(string)$locationData['lon'] ?? null,
250+
($lat !== null) ? (string)$lat : $lat,
251+
($lon !== null) ? (string)$lon : $lon,
249252
$locationData['timezone'] ?? null,
250253
$locationData['region'] ?? null,
251254
$locationData['country'] ?? null,

0 commit comments

Comments
 (0)