99 * @license MIT License
1010 */
1111
12- use Geocoder \Dumper \GeoJson ;
12+ use ReflectionClass ;
13+ use Geocoder \Geocoder ;
1314use Geocoder \Dumper \Gpx ;
1415use Geocoder \Dumper \Kml ;
1516use Geocoder \Dumper \Wkb ;
1617use Geocoder \Dumper \Wkt ;
17- use Geocoder \Geocoder ;
18- use Geocoder \Laravel \Exceptions \InvalidDumperException ;
18+ use Geocoder \Query \Query ;
19+ use Illuminate \Support \Str ;
20+ use Geocoder \Dumper \GeoJson ;
1921use Geocoder \ProviderAggregator ;
2022use Geocoder \Query \GeocodeQuery ;
21- use Geocoder \Query \Query ;
2223use Geocoder \Query \ReverseQuery ;
2324use Illuminate \Support \Collection ;
24- use ReflectionClass ;
25+ use Geocoder \ Laravel \ Exceptions \ InvalidDumperException ;
2526
2627/**
2728 * @SuppressWarnings(PHPMD.TooManyPublicMethods)
@@ -73,6 +74,7 @@ public function dump(string $dumper) : Collection
7374 "The dumper specified (' {$ dumper }') is invalid. Valid dumpers " ,
7475 "are: geojson, gpx, kml, wkb, wkt. " ,
7576 ]);
77+
7678 throw new InvalidDumperException ($ errorMessage );
7779 }
7880
@@ -87,7 +89,7 @@ public function dump(string $dumper) : Collection
8789
8890 public function geocode (string $ value ) : self
8991 {
90- $ cacheKey = str_slug (strtolower (urlencode ($ value )));
92+ $ cacheKey = Str:: slug (strtolower (urlencode ($ value )));
9193 $ this ->results = $ this ->cacheRequest ($ cacheKey , [$ value ], "geocode " );
9294
9395 return $ this ;
@@ -156,7 +158,7 @@ public function registerProvidersFromConfig(Collection $providers) : self
156158
157159 public function reverse (float $ latitude , float $ longitude ) : self
158160 {
159- $ cacheKey = str_slug (strtolower (urlencode ("{$ latitude }- {$ longitude }" )));
161+ $ cacheKey = Str:: slug (strtolower (urlencode ("{$ latitude }- {$ longitude }" )));
160162 $ this ->results = $ this ->cacheRequest ($ cacheKey , [$ latitude , $ longitude ], "reverse " );
161163
162164 return $ this ;
@@ -191,13 +193,15 @@ protected function cacheRequest(string $cacheKey, array $queryElements, string $
191193 "value " => collect ($ this ->aggregator ->{$ queryType }(...$ queryElements )),
192194 ];
193195 });
196+
194197 $ result = $ this ->preventCacheKeyHashCollision (
195198 $ result ,
196199 $ hashedCacheKey ,
197200 $ cacheKey ,
198201 $ queryElements ,
199202 $ queryType
200203 );
204+
201205 $ this ->removeEmptyCacheEntry ($ result , $ hashedCacheKey );
202206
203207 return $ result ;
0 commit comments