9
9
* @license MIT License
10
10
*/
11
11
12
- use Geocoder \Dumper \GeoJson ;
12
+ use ReflectionClass ;
13
+ use Geocoder \Geocoder ;
13
14
use Geocoder \Dumper \Gpx ;
14
15
use Geocoder \Dumper \Kml ;
15
16
use Geocoder \Dumper \Wkb ;
16
17
use 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 ;
19
21
use Geocoder \ProviderAggregator ;
20
22
use Geocoder \Query \GeocodeQuery ;
21
- use Geocoder \Query \Query ;
22
23
use Geocoder \Query \ReverseQuery ;
23
24
use Illuminate \Support \Collection ;
24
- use ReflectionClass ;
25
+ use Geocoder \ Laravel \ Exceptions \ InvalidDumperException ;
25
26
26
27
/**
27
28
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
@@ -73,6 +74,7 @@ public function dump(string $dumper) : Collection
73
74
"The dumper specified (' {$ dumper }') is invalid. Valid dumpers " ,
74
75
"are: geojson, gpx, kml, wkb, wkt. " ,
75
76
]);
77
+
76
78
throw new InvalidDumperException ($ errorMessage );
77
79
}
78
80
@@ -87,7 +89,7 @@ public function dump(string $dumper) : Collection
87
89
88
90
public function geocode (string $ value ) : self
89
91
{
90
- $ cacheKey = str_slug (strtolower (urlencode ($ value )));
92
+ $ cacheKey = Str:: slug (strtolower (urlencode ($ value )));
91
93
$ this ->results = $ this ->cacheRequest ($ cacheKey , [$ value ], "geocode " );
92
94
93
95
return $ this ;
@@ -156,7 +158,7 @@ public function registerProvidersFromConfig(Collection $providers) : self
156
158
157
159
public function reverse (float $ latitude , float $ longitude ) : self
158
160
{
159
- $ cacheKey = str_slug (strtolower (urlencode ("{$ latitude }- {$ longitude }" )));
161
+ $ cacheKey = Str:: slug (strtolower (urlencode ("{$ latitude }- {$ longitude }" )));
160
162
$ this ->results = $ this ->cacheRequest ($ cacheKey , [$ latitude , $ longitude ], "reverse " );
161
163
162
164
return $ this ;
@@ -191,13 +193,15 @@ protected function cacheRequest(string $cacheKey, array $queryElements, string $
191
193
"value " => collect ($ this ->aggregator ->{$ queryType }(...$ queryElements )),
192
194
];
193
195
});
196
+
194
197
$<
6D0B
/span>result = $ this ->preventCacheKeyHashCollision (
195
198
$ result ,
196
199
$ hashedCacheKey ,
197
200
$ cacheKey ,
198
201
$ queryElements ,
199
202
$ queryType
200
203
);
204
+
201
205
$ this ->removeEmptyCacheEntry ($ result , $ hashedCacheKey );
202
206
203
207
return $ result ;
0 commit comments