Skip to content

Commit 237665a

Browse files
committed
Merge branch 'master' of github.com:geocoder-php/GeocoderLaravel into develop
2 parents a133cca + 1477889 commit 237665a

File tree

7 files changed

+36
-28
lines changed

7 files changed

+36
-28
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [4.0.21] - 3 Nov 2018
6+
### Added
7+
- `->toJson()` method when querying results.
8+
9+
## [4.0.10] - 1 Jul 2018
10+
### Changed
11+
- service provider to register singleton and alias in `register()` method.
12+
513
## [4.0.9] - 28 May 2018
614
### Added
715
- class-name resolution from Service container, allowing for dependency

composer.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,26 @@
2727
"geocoder-php/geo-plugin-provider": "^4.0",
2828
"geocoder-php/google-maps-provider": "^4.0",
2929
"guzzlehttp/psr7": "*",
30-
"illuminate/cache": "5.0 - 5.6",
31-
"illuminate/support": "5.0 - 5.6",
32-
"php-http/curl-client": "^1.7",
30+
"http-interop/http-factory-guzzle": "^1.0",
31+
"illuminate/cache": "5.0 - 5.8",
32+
"illuminate/support": "5.0 - 5.8",
33+
"php-http/curl-client": "*",
3334
"php": ">=7.1.3",
3435
"willdurand/geocoder": "^4.0"
3536
},
3637
"require-dev": {
37-
"codedungeon/phpunit-result-printer": "*",
38-
"doctrine/dbal": "^2.5",
39-
"fzaninotto/faker": "~1.4",
38+
"doctrine/dbal": "*",
39+
"fzaninotto/faker": "*",
4040
"geocoder-php/bing-maps-provider": "^4.0",
4141
"geocoder-php/geoip2-provider": "^4.0",
4242
"geocoder-php/maxmind-binary-provider": "^4.0",
43-
"mockery/mockery": "0.9.*",
44-
"orchestra/database": "3.6.*",
45-
"orchestra/testbench": "3.6.*",
46-
"orchestra/testbench-browser-kit": "3.6.*",
47-
"orchestra/testbench-dusk": "3.6.x-dev@dev",
43+
"mockery/mockery": "*",
44+
"orchestra/testbench-browser-kit": "3.8.*",
45+
"orchestra/database": "3.8.x-dev@dev",
46+
"orchestra/testbench-dusk": "3.8.x-dev@dev",
47+
"orchestra/testbench": "3.8.*",
4848
"php-coveralls/php-coveralls": "*",
49-
"phpunit/phpunit": "^7.0",
49+
"phpunit/phpunit": "^7.5",
5050
"sebastian/phpcpd": "*"
5151
},
5252
"autoload": {

phpunit.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
convertErrorsToExceptions="true"
88
convertNoticesToExceptions="true"
99
convertWarningsToExceptions="true"
10-
printerClass="Codedungeon\PHPUnitPrettyResultPrinter\Printer"
1110
processIsolation="false"
12-
stopOnFailure="false"
13-
syntaxCheck="false"
11+
stopOnFailure="true"
1412
>
1513
<testsuites>
1614
<testsuite name="Browser">

src/ProviderAndDumperAggregator.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@
1414
use Geocoder\Dumper\Kml;
1515
use Geocoder\Dumper\Wkb;
1616
use Geocoder\Dumper\Wkt;
17-
use Geocoder\Geocoder;
1817
use Geocoder\Laravel\Exceptions\InvalidDumperException;
1918
use Geocoder\ProviderAggregator;
2019
use Geocoder\Query\GeocodeQuery;
21-
use Geocoder\Query\Query;
2220
use Geocoder\Query\ReverseQuery;
2321
use Illuminate\Support\Collection;
22+
use Illuminate\Support\Str;
2423
use ReflectionClass;
2524

2625
/**
@@ -51,6 +50,13 @@ public function get() : Collection
5150
return $this->results;
5251
}
5352

53+
public function toJson() : string
54+
{
55+
return $this
56+
->dump("geojson")
57+
->first();
58+
}
59+
5460
public function dump(string $dumper) : Collection
5561
{
5662
$dumperClasses = collect([
@@ -66,6 +72,7 @@ public function dump(string $dumper) : Collection
6672
"The dumper specified ('{$dumper}') is invalid. Valid dumpers ",
6773
"are: geojson, gpx, kml, wkb, wkt.",
6874
]);
75+
6976
throw new InvalidDumperException($errorMessage);
7077
}
7178

@@ -80,7 +87,7 @@ public function dump(string $dumper) : Collection
8087

8188
public function geocode(string $value) : self
8289
{
83-
$cacheKey = str_slug(strtolower(urlencode($value)));
90+
$cacheKey = (new Str)->slug(strtolower(urlencode($value)));
8491
$this->results = $this->cacheRequest($cacheKey, [$value], "geocode");
8592

8693
return $this;
@@ -149,7 +156,7 @@ public function registerProvidersFromConfig(Collection $providers) : self
149156

150157
public function reverse(float $latitude, float $longitude) : self
151158
{
152-
$cacheKey = str_slug(strtolower(urlencode("{$latitude}-{$longitude}")));
159+
$cacheKey = (new Str)->slug(strtolower(urlencode("{$latitude}-{$longitude}")));
153160
$this->results = $this->cacheRequest($cacheKey, [$latitude, $longitude], "reverse");
154161

155162
return $this;
@@ -184,13 +191,15 @@ protected function cacheRequest(string $cacheKey, array $queryElements, string $
184191
"value" => collect($this->aggregator->{$queryType}(...$queryElements)),
185192
];
186193
});
194+
187195
$result = $this->preventCacheKeyHashCollision(
188196
$result,
189197
$hashedCacheKey,
190198
$cacheKey,
191199
$queryElements,
192200
$queryType
193201
);
202+
194203
$this->removeEmptyCacheEntry($result, $hashedCacheKey);
195204

196205
return $result;

tests/CreatesApplication.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
trait CreatesApplication
77
{
8-
public function setUp()
8+
public function setUp() : void
99
{
1010
parent::setUp();
1111

tests/Feature/Providers/GeocoderServiceTest.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,8 @@ public function testItResolvesAGivenAddressWithUmlauts()
8181

8282
public function testItResolvesAGivenAddressWithUmlautsInRegion()
8383
{
84-
config()->set('geocoder.providers.Geocoder\Provider\Chain\Chain.Geocoder\Provider\GoogleMaps\GoogleMaps', [
85-
'de-DE',
86-
null,
87-
]);
88-
app()->register(GeocoderService::class);
89-
9084
$results = app('geocoder')
91-
->geocode('Obere Donaustrasse 22, Wien, Österreich')
85+
->geocode('Obere Donaustraße 22, Wien, Österreich')
9286
->get();
9387

9488
$this->assertEquals('22', $results->first()->getStreetNumber());

tests/config/testConfig.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use Geocoder\Provider\GeoIP2\GeoIP2;
1212
use Geocoder\Provider\GeoPlugin\GeoPlugin;
1313
use Geocoder\Provider\GoogleMaps\GoogleMaps;
14-
use Geocoder\Provider\HostIp\HostIp;
1514
use GeoIp2\Database\Reader;
1615
use Http\Client\Curl\Client;
1716

0 commit comments

Comments
 (0)