@@ -157,25 +157,23 @@ protected function executeQuery($query)
157
157
}
158
158
159
159
// Make sure that we do have proper result array
160
- if (empty ($ response ['locations ' ]) || !is_array ($ response ['locations ' ]) || empty ( $ response [ ' locations ' ][ 0 ])) {
160
+ if (empty ($ response ['location ' ]) || !is_array ($ response ['location ' ])) {
161
161
throw new NoResultException (sprintf ('Invalid response from GeoIPs server for query %s ' , $ query ));
162
162
}
163
163
164
- // Pick the first location from the response
165
164
$ locations = array ();
166
- foreach ($ response ['locations ' ] as $ location ) {
167
- $ locations [] = array_merge ($ this ->getDefaults (), array (
168
- 'country ' => '' === $ location ['country_name ' ] ? null : $ location ['country_name ' ],
169
- 'countryCode ' => '' === $ location ['country_code ' ] ? null : $ location ['country_code ' ],
170
- 'region ' => '' === $ location ['region_name ' ] ? null : $ location ['region_name ' ],
171
- 'regionCode ' => '' === $ location ['region_code ' ] ? null : $ location ['region_code ' ],
172
- 'county ' => '' === $ location ['county_name ' ] ? null : $ location ['county_name ' ],
173
- 'city ' => '' === $ location ['city_name ' ] ? null : $ location ['city_name ' ],
174
- 'latitude ' => '' === $ location ['latitude ' ] ? null : $ location ['latitude ' ],
175
- 'longitude ' => '' === $ location ['longitude ' ] ? null : $ location ['longitude ' ],
176
- 'timezone ' => '' === $ location ['timezone ' ] ? null : $ location ['timezone ' ],
177
- ));
178
- }
165
+ $ location = $ response ['location ' ];
166
+ $ locations [] = array_merge ($ this ->getDefaults (), array (
167
+ 'country ' => '' === $ location ['country_name ' ] ? null : $ location ['country_name ' ],
168
+ 'countryCode ' => '' === $ location ['country_code ' ] ? null : $ location ['country_code ' ],
169
+ 'region ' => '' === $ location ['region_name ' ] ? null : $ location ['region_name ' ],
170
+ 'regionCode ' => '' === $ location ['region_code ' ] ? null : $ location ['region_code ' ],
171
+ 'county ' => '' === $ location ['county_name ' ] ? null : $ location ['county_name ' ],
172
+ 'city ' => '' === $ location ['city_name ' ] ? null : $ location ['city_name ' ],
173
+ 'latitude ' => '' === $ location ['latitude ' ] ? null : $ location ['latitude ' ],
174
+ 'longitude ' => '' === $ location ['longitude ' ] ? null : $ location ['longitude ' ],
175
+ 'timezone ' => '' === $ location ['timezone ' ] ? null : $ location ['timezone ' ],
176
+ ));
179
177
180
178
return $ locations ;
181
179
}
0 commit comments