Skip to content

Commit

Permalink
Fix type casting for null lat & lon location data
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaalyn committed Mar 13, 2022
1 parent ea1f472 commit 2e0c3aa
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Dto/LocationDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,13 @@ public function setMessage(string $message): LocationDto
*/
public static function fromArray(array $locationData): self
{
$lat = $locationData['lat'] ?? null;
$lon = $locationData['lon'] ?? null;

return new self(
$locationData['status'],
(string)$locationData['lat'] ?? null,
(string)$locationData['lon'] ?? null,
($lat !== null) ? (string)$lat : $lat,
($lon !== null) ? (string)$lon : $lon,
$locationData['timezone'] ?? null,
$locationData['region'] ?? null,
$locationData['country'] ?? null,
Expand Down

0 comments on commit 2e0c3aa

Please sign in to comment.