8000 Merge pull request #149 from nmfzone/patch-2 · geocoder-php/GeocoderLaravel@007358f · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 007358f

Browse files
authored
Merge pull request #149 from nmfzone/patch-2
chore: Sort imports and use Str class directly (not via helpers)
2 parents de6047c + 367f2a1 commit 007358f

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/ProviderAndDumperAggregator.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,20 @@
99
* @license MIT License
1010
*/
1111

12-
use Geocoder\Dumper\GeoJson;
12+
use ReflectionClass;
13+
use Geocoder\Geocoder;
1314
use Geocoder\Dumper\Gpx;
1415
use Geocoder\Dumper\Kml;
1516
use Geocoder\Dumper\Wkb;
1617
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;
1921
use Geocoder\ProviderAggregator;
2022
use Geocoder\Query\GeocodeQuery;
21-
use Geocoder\Query\Query;
2223
use Geocoder\Query\ReverseQuery;
2324
use 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

Comments
 (0)
0