Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e7fbe59

Browse files
committed
Merge pull request #461 from geocoder-php/fix-geoip2
Fix postal code for GeoIP2 provider
2 parents 38b4f20 + 0dfa58d commit e7fbe59

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/Geocoder/Provider/GeoIP2.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function geocode($address)
7171
'latitude' => (isset($result->location->latitude) ? $result->location->latitude : null),
7272
'longitude' => (isset($result->location->longitude) ? $result->location->longitude : null),
7373
'timezone' => (isset($result->location->time_zone) ? $result->location->time_zone : null),
74-
'postalCode' => (isset($result->location->postal_code) ? $result->location->postal_code : null),
74+
'postalCode' => (isset($result->postal->code) ? $result->postal->code : null),
7575
'adminLevels' => $adminLevels,
7676
)))
7777
]);

tests/Geocoder/Tests/Provider/GeoIP2Test.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public static function provideDataForRetrievingGeodata()
7676
$testdata = array(
7777
'Response with data' => array(
7878
'74.200.247.59',
79-
'{"city":{"geoname_id":2911298,"names":{"de":"Hamburg","en":"Hamburg","es":"Hamburgo","fr":"Hambourg","ja":"\u30cf\u30f3\u30d6\u30eb\u30af","pt-BR":"Hamburgo","ru":"\u0413\u0430\u043c\u0431\u0443\u0440\u0433","zh-CN":"\u6c49\u5821\u5e02"}},"continent":{"code":"EU","geoname_id":6255148,"names":{"de":"Europa","en":"Europe","es":"Europa","fr":"Europe","ja":"\u30e8\u30fc\u30ed\u30c3\u30d1","pt-BR":"Europa","ru":"\u0415\u0432\u0440\u043e\u043f\u0430","zh-CN":"\u6b27\u6d32"}},"country":{"geoname_id":2921044,"iso_code":"DE","names":{"de":"Deutschland","en":"Germany","es":"Alemania","fr":"Allemagne","ja":"\u30c9\u30a4\u30c4\u9023\u90a6\u5171\u548c\u56fd","pt-BR":"Alemanha","ru":"\u0413\u0435\u0440\u043c\u0430\u043d\u0438\u044f","zh-CN":"\u5fb7\u56fd"}},"location":{"latitude":53.55,"longitude":10,"time_zone":"Europe\/Berlin"},"registered_country":{"geoname_id":2921044,"iso_code":"DE","names":{"de":"Deutschland","en":"Germany","es":"Alemania","fr":"Allemagne","ja":"\u30c9\u30a4\u30c4\u9023\u90a6\u5171\u548c\u56fd","pt-BR":"Alemanha","ru":"\u0413\u0435\u0440\u043c\u0430\u043d\u0438\u044f","zh-CN":"\u5fb7\u56fd"}},"subdivisions":[{"geoname_id":2911297,"iso_code":"HH","names":{"de":"Hamburg","en":"Hamburg","es":"Hamburgo","fr":"Hambourg"}}],"traits":{"ip_address":"74.200.247.59"}}',
79+
'{"city":{"geoname_id":2911298,"names":{"de":"Hamburg","en":"Hamburg","es":"Hamburgo","fr":"Hambourg","ja":"\u30cf\u30f3\u30d6\u30eb\u30af","pt-BR":"Hamburgo","ru":"\u0413\u0430\u043c\u0431\u0443\u0440\u0433","zh-CN":"\u6c49\u5821\u5e02"}},"continent":{"code":"EU","geoname_id":6255148,"names":{"de":"Europa","en":"Europe","es":"Europa","fr":"Europe","ja":"\u30e8\u30fc\u30ed\u30c3\u30d1","pt-BR":"Europa","ru":"\u0415\u0432\u0440\u043e\u043f\u0430","zh-CN":"\u6b27\u6d32"}},"country":{"geoname_id":2921044,"iso_code":"DE","names":{"de":"Deutschland","en":"Germany","es":"Alemania","fr":"Allemagne","ja":"\u30c9\u30a4\u30c4\u9023\u90a6\u5171\u548c\u56fd","pt-BR":"Alemanha","ru":"\u0413\u0435\u0440\u043c\u0430\u043d\u0438\u044f","zh-CN":"\u5fb7\u56fd"}},"location":{"latitude":53.55,"longitude":10,"time_zone":"Europe\/Berlin"},"registered_country":{"geoname_id":2921044,"iso_code":"DE","names":{"de":"Deutschland","en":"Germany","es":"Alemania","fr":"Allemagne","ja":"\u30c9\u30a4\u30c4\u9023\u90a6\u5171\u548c\u56fd","pt-BR":"Alemanha","ru":"\u0413\u0435\u0440\u043c\u0430\u043d\u0438\u044f","zh-CN":"\u5fb7\u56fd"}},"subdivisions":[{"geoname_id":2911297,"iso_code":"HH","names":{"de":"Hamburg","en":"Hamburg","es":"Hamburgo","fr":"Hambourg"}}],"traits":{"ip_address":"74.200.247.59"},"postal":{"code":"EC4N"}}',
8080
array(
8181
'latitude' => 53.55,
8282
'longitude' => 10,
@@ -85,7 +85,7 @@ public static function provideDataForRetrievingGeodata()
8585
'streetName' => null,
8686
'locality' => 'Hamburg',
8787
'subLocality' => null,
88-
'postalCode' => null,
88+
'postalCode' => 'EC4N',
8989
'adminLevels' => [1 => [
9090
'name' => 'Hamburg',
9191
'code' => 'HH',
@@ -106,7 +106,7 @@ public static function provideDataForRetrievingGeodata()
106106
'streetName' => null,
107107
'locality' => 'Monza',
108108
'subLocality' => null,
109-
'postalCode' => null,
109+
'postalCode' => '20900',
110110
'adminLevels' => [
111111
1 => [
112112
'name' => 'Lombardy',

0 commit comments

Comments
 (0)