- if ('state' === $sTypeLabel && !empty($aLine['name'])) {
- $this->addStateCode($aAddress, $aLine['name']);
+ if (!empty($aLine['name'])) {
+ $this->addSubdivisionCode($aAddress, $aLine['admin_level'], $aLine['name']);
- /**
- * Add `state_code` field to address details to represent second part of ISO 3166-2 country subdivision code
- */
- private function addStateCode(&$aAddress, $nameDetails)
+ private function addSubdivisionCode(&$aAddress, $iAdminLevel, $nameDetails)
{
if (is_string($nameDetails)) {
$nameDetails = json_decode('{' . str_replace('"=>"', '":"', $nameDetails) . '}', true);
}
{
if (is_string($nameDetails)) {
$nameDetails = json_decode('{' . str_replace('"=>"', '":"', $nameDetails) . '}', true);
}