@@ -157,25 +157,23 @@ protected function executeQuery($query)
157157 }
158158
159159 // 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 ' ])) {
161161 throw new NoResultException (sprintf ('Invalid response from GeoIPs server for query %s ' , $ query ));
162162 }
163163
164- // Pick the first location from the response
165164 $ 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+ ));
179177
180178 return $ locations ;
181179 }
0 commit comments