Skip to content

Commit dc68e55

Browse files
committed
Added country code to response object (Place)
1 parent fef922c commit dc68e55

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

src/Objects/Place.php

+25
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ class Place
9191
*/
9292
protected $mainNeighborhood;
9393

94+
/**
95+
* @var string|null
96+
*/
97+
protected $countryCode;
98+
9499
/**
95100
* @return string
96101
*/
@@ -634,4 +639,24 @@ public function setMainNeighborhood(?string $mainNeighborhood): Place
634639

635640
return $this;
636641
}
642+
643+
/**
644+
* @return null|string
645+
*/
646+
public function getCountryCode(): ?string
647+
{
648+
return $this->countryCode;
649+
}
650+
651+
/**
652+
* @param null|string $countryCode
653+
*
654+
* @return Place
655+
*/
656+
public function setCountryCode(?string $countryCode): Place
657+
{
658+
$this->countryCode = $countryCode;
659+
660+
return $this;
661+
}
637662
}

src/PlaceSimpleFactory.php

+15
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,21 @@ protected function setAdministrativeAreaLevel1(array $component, Place $place):
171171
return $place;
172172
}
173173

174+
/**
175+
* @param mixed[] $component
176+
* @param Place $place
177+
*
178+
* @return Place
179+
*/
180+
protected function setCountry(array $component, Place $place)
181+
{
182+
if ($place->getCountryCode() === null) {
183+
$place->setCountryCode($component['short_name']);
184+
}
185+
186+
return $place;
187+
}
188+
174189
/**
175190
* @param mixed[] $component
176191
* @param Place $place

0 commit comments

Comments
 (0)