Skip to content

Commit 26730ff

Browse files
StadlyNyholm
authored andcommitted
GeoPlugin: Return empty collection if address was not found (#814)
* Return empty collection if address was not found If the location of the ip address cannot be determined by GeoPlugin, return an empty AddressCollection instead of dummy data. This is particularly useful when using the Chain provider. * Fix code style Fix code style
1 parent f4fe7df commit 26730ff

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

GeoPlugin.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,17 @@ private function executeQuery(string $url): AddressCollection
8585
return new AddressCollection([]);
8686
}
8787

88+
// Return empty collection if address was not found
89+
if ('' === $json['geoplugin_regionName']
90+
&& '' === $json['geoplugin_regionCode']
91+
&& '' === $json['geoplugin_city']
92+
&& '' === $json['geoplugin_countryName']
93+
&& '' === $json['geoplugin_countryCode']
94+
&& '0' === $json['geoplugin_latitude']
95+
&& '0' === $json['geoplugin_longitude']) {
96+
return new AddressCollection([]);
97+
}
98+
8899
$data = array_filter($json);
89100

90101
$adminLevels = [];

0 commit comments

Comments
 (0)