8000 Update GeoPlugin provider · geocoder-php/Geocoder@9c926c1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9c926c1

Browse files
committed
Update GeoPlugin provider
1 parent 7f25d71 commit 9c926c1

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/Geocoder/Provider/GeoPlugin.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,21 @@ private function executeQuery($query)
8080

8181
$data = array_filter($json);
8282

83+
$admins = [];
84+
85+
$region = \igorw\get_in($data, ['geoplugin_regionName']);
86+
$regionCode = \igorw\get_in($data, ['geoplugin_regionCode']);
87+
88+
if (null !== $region || null !== $regionCode) {
89+
$admins[0] = ['name' => $region, 'code' => $regionCode];
90+
}
91+
8392
$results = [];
8493
$results[] = array_merge($this->getDefaults(), [
8594
'locality' => isset($data['geoplugin_city']) ? $data['geoplugin_city'] : null,
8695
'country' => isset($data['geoplugin_countryName']) ? $data['geoplugin_countryName'] : null,
8796
'countryCode' => isset($data['geoplugin_countryCode']) ? $data['geoplugin_countryCode'] : null,
88-
'region' => isset($data['geoplugin_regionName']) ? $data['geoplugin_regionName'] : null,
89-
'regionCode' => isset($data['geoplugin_regionCode']) ? $data['geoplugin_regionCode'] : null,
97+
'admins' => $admins,
9098
'latitude' => isset($data['geoplugin_latitude']) ? $data['geoplugin_latitude'] : null,
9199
'longitude' => isset($data['geoplugin_longitude']) ? $data['geoplugin_longitude'] : null,
92100
]);

tests/Geocoder/Tests/Provider/GeoPluginTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ public function testGeocodeWithLocalhostIPv4()
5353

5454
$result = $results->first();
5555
$this->assertEquals('localhost', $result->getLocality());
56-
$this->assertEquals('localhost', $result->getAdmins()[1]->getName());
57-
$this->assertEquals('localhost', $result->getAdmins()[0]->getName());
5856
$this->assertEquals('localhost', $result->getCountry()->getName());
5957
}
6058 6D8C

@@ -68,8 +66,6 @@ public function testGeocodeWithLocalhostIPv6()
6866

6967
$result = $results->first();
7068
$this->assertEquals('localhost', $result->getLocality());
71-
$this->assertEquals('localhost', $result->getAdmins()[1]->getName());
72-
$this->assertEquals('localhost', $result->getAdmins()[0]->getName());
7369
$this->assertEquals('localhost', $result->getCountry()->getName());
7470
}
7571

0 commit comments

Comments
 (0)
0