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 2cd8813

Browse filesBrowse 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
Copy full SHA for 2cd8813

File tree

3 files changed

+25
-4
lines changed
Filter options

3 files changed

+25
-4
lines changed

‎CHANGELOG.md

Copy file name to clipboardExpand all lines: CHANGELOG.md
+8Lines 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

Copy file name to clipboardExpand all lines: src/ProviderAndDumperAggregator.php
+8-4Lines 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

Copy file name to clipboardExpand all lines: tests/Feature/Providers/GeocoderServiceTest.php
+9Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.