Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/ProviderAndDumperAggregator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@
* @license MIT License
*/

use Geocoder\Dumper\GeoJson;
use ReflectionClass;
use Geocoder\Geocoder;
use Geocoder\Dumper\Gpx;
use Geocoder\Dumper\Kml;
use Geocoder\Dumper\Wkb;
use Geocoder\Dumper\Wkt;
use Geocoder\Geocoder;
use Geocoder\Laravel\Exceptions\InvalidDumperException;
use Geocoder\Query\Query;
use Illuminate\Support\Str;
use Geocoder\Dumper\GeoJson;
use Geocoder\ProviderAggregator;
use Geocoder\Query\GeocodeQuery;
use Geocoder\Query\Query;
use Geocoder\Query\ReverseQuery;
use Illuminate\Support\Collection;
use ReflectionClass;
use Geocoder\Laravel\Exceptions\InvalidDumperException;

/**
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
Expand Down Expand Up @@ -73,6 +74,7 @@ public function dump(string $dumper) : Collection
"The dumper specified ('{$dumper}') is invalid. Valid dumpers ",
"are: geojson, gpx, kml, wkb, wkt.",
]);

throw new InvalidDumperException($errorMessage);
}

Expand All @@ -87,7 +89,7 @@ public function dump(string $dumper) : Collection

public function geocode(string $value) : self
{
$cacheKey = str_slug(strtolower(urlencode($value)));
$cacheKey = Str::slug(strtolower(urlencode($value)));
$this->results = $this->cacheRequest($cacheKey, [$value], "geocode");

return $this;
Expand Down Expand Up @@ -156,7 +158,7 @@ public function registerProvidersFromConfig(Collection $providers) : self

public function reverse(float $latitude, float $longitude) : self
{
$cacheKey = str_slug(strtolower(urlencode("{$latitude}-{$longitude}")));
$cacheKey = Str::slug(strtolower(urlencode("{$latitude}-{$longitude}")));
$this->results = $this->cacheRequest($cacheKey, [$latitude, $longitude], "reverse");

return $this;
Expand Down Expand Up @@ -191,13 +193,15 @@ protected function cacheRequest(string $cacheKey, array $queryElements, string $
"value" => collect($this->aggregator->{$queryType}(...$queryElements)),
];
});

$result = $this->preventCacheKeyHashCollision(
$result,
$hashedCacheKey,
$cacheKey,
$queryElements,
$queryType
);

$this->removeEmptyCacheEntry($result, $hashedCacheKey);

return $result;
Expand Down