8000 Changed `getProvider()` method to no longer be deprecated, and instea… · geocoder-php/GeocoderLaravel@2cd8813 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2cd8813

Browse files
committed
Changed getProvider() method to no longer be deprecated, and instead return the currently set provider, or if none set, the first configured provider.
1 parent 41f22b3 commit 2cd8813

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
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.3.4] - 2020-06-21
6+
### Fixed
7+
- non-caching declaration to only apply to current query.
8+
9+
### Changed
10+
- `getProvider()` method to no longer be deprecated, and instead return the
11+
currently set provider, or if none set, the first configured provider.
12+
513
## [4.3.3] - 2020-06-20
614
### Added
715
- functionality to not cache requests by using `doNotCache()`.

src/ProviderAndDumperAggregator.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,14 @@ public function limit(int $limit) : self
130130
return $this;
131131
}
132132

133-
/**
134-
* @deprecated Use `getProviders()` instead.
135-
*/
136133
public function getProvider()
137134
{
138-
return $this->getProviders()->first();
135+
$reflectedClass = new ReflectionClass(ProviderAggregator::class);
136+
$reflectedProperty = $reflectedClass->getProperty('provider');
137+
$reflectedProperty->setAccessible(true);
138+
139+
return $reflectedProperty->getValue($this->aggregator)
140+
?? $this->getProviders()->first();
139141
}
140142

141143
public function getProviders() : Collection
@@ -190,6 +192,8 @@ public function using(string $name) : self
190192
protected function cacheRequest(string $cacheKey, array $queryElements, string $queryType)
191193
{
192194
if (! $this->isCaching) {
195+
$this->isCaching = true;
196+
193197
return collect($this->aggregator->{$queryType}(...$queryElements));
194198
}
195199

tests/Feature/Providers/GeocoderServiceTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,4 +326,13 @@ public function testCachingCanBeDisabled()
326326
$results->first()->getFormattedAddress()
327327
);
328328
}
329+
330+
public function testGetProviderReturnsCurrentProvider()
331+
{
332+
$provider = app("geocoder")
333+
->using("google_maps")
334+
->getProvider();
335+
336+
$this->assertEquals("google_maps", $provider->getName());
337+
}
329338
}

0 commit comments

Comments
 (0)
0