Skip to content

Commit

Permalink
Merge pull request #149 from nmfzone/patch-2
Browse files Browse the repository at this point in the history
chore: Sort imports and use Str class directly (not via helpers)
  • Loading branch information
mikebronner committed Mar 12, 2019
2 parents de6047c + 367f2a1 commit 007358f
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/ProviderAndDumperAggregator.php
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

0 comments on commit 007358f

Please sign in to comment.