Skip to content

Commit

Permalink
Merge pull request #461 from geocoder-php/fix-geoip2
Browse files Browse the repository at this point in the history
Fix postal code for GeoIP2 provider
  • Loading branch information
willdurand committed Oct 9, 2015
2 parents 38b4f20 + 0dfa58d commit e7fbe59
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Geocoder/Provider/GeoIP2.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function geocode($address)
'latitude' => (isset($result->location->latitude) ? $result->location->latitude : null),
'longitude' => (isset($result->location->longitude) ? $result->location->longitude : null),
'timezone' => (isset($result->location->time_zone) ? $result->location->time_zone : null),
'postalCode' => (isset($result->location->postal_code) ? $result->location->postal_code : null),
'postalCode' => (isset($result->postal->code) ? $result->postal->code : null),
'adminLevels' => $adminLevels,
)))
]);
Expand Down
6 changes: 3 additions & 3 deletions tests/Geocoder/Tests/Provider/GeoIP2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static function provideDataForRetrievingGeodata()
$testdata = array(
'Response with data' => array(
'74.200.247.59',
'{"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"}}',
'{"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"}}',
array(
'latitude' => 53.55,
'longitude' => 10,
Expand All @@ -85,7 +85,7 @@ public static function provideDataForRetrievingGeodata()
'streetName' => null,
'locality' => 'Hamburg',
'subLocality' => null,
'postalCode' => null,
'postalCode' => 'EC4N',
'adminLevels' => [1 => [
'name' => 'Hamburg',
'code' => 'HH',
Expand All @@ -106,7 +106,7 @@ public static function provideDataForRetrievingGeodata()
'streetName' => null,
'locality' => 'Monza',
'subLocality' => null,
'postalCode' => null,
'postalCode' => '20900',
'adminLevels' => [
1 => [
'name' => 'Lombardy',
Expand Down

0 comments on commit e7fbe59

Please sign in to comment.