From a420fee71150319abacb34c0d474b8f0329e3f7c Mon Sep 17 00:00:00 2001 From: Tim Bond Date: Thu, 15 Mar 2018 10:21:08 -0700 Subject: [PATCH] Make ProviderCache not final --- src/Provider/Cache/CHANGELOG.md | 4 ++++ src/Provider/Cache/ProviderCache.php | 16 ++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Provider/Cache/CHANGELOG.md b/src/Provider/Cache/CHANGELOG.md index 4e2855d35..76969c0f6 100644 --- a/src/Provider/Cache/CHANGELOG.md +++ b/src/Provider/Cache/CHANGELOG.md @@ -2,6 +2,10 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release. +## 4.1.0 (2018-03-16) + +* Changed: `ProviderCache` is no longer final allowing `ProviderCache::getCacheKey` to be overridden + ## 4.0.1 ### Changed diff --git a/src/Provider/Cache/ProviderCache.php b/src/Provider/Cache/ProviderCache.php index afbf95619..00fa53b9c 100644 --- a/src/Provider/Cache/ProviderCache.php +++ b/src/Provider/Cache/ProviderCache.php @@ -26,26 +26,26 @@ final class ProviderCache implements Provider /** * @var Provider */ - private $realProvider; + protected $realProvider; /** * @var CacheInterface */ - private $cache; + protected $cache; /** * How log a result is going to be cached. * * @var int|null */ - private $lifetime; + protected $lifetime; /** * @param Provider $realProvider * @param CacheInterface $cache * @param int $lifetime */ - public function __construct(Provider $realProvider, CacheInterface $cache, int $lifetime = null) + final public function __construct(Provider $realProvider, CacheInterface $cache, int $lifetime = null) { $this->realProvider = $realProvider; $this->cache = $cache; @@ -55,7 +55,7 @@ public function __construct(Provider $realProvider, CacheInterface $cache, int $ /** * {@inheritdoc} */ - public function geocodeQuery(GeocodeQuery $query): Collection + final public function geocodeQuery(GeocodeQuery $query): Collection { $cacheKey = $this->getCacheKey($query); if (null !== $result = $this->cache->get($cacheKey)) { @@ -71,7 +71,7 @@ public function geocodeQuery(GeocodeQuery $query): Collection /** * {@inheritdoc} */ - public function reverseQuery(ReverseQuery $query): Collection + final public function reverseQuery(ReverseQuery $query): Collection { $cacheKey = $this->getCacheKey($query); if (null !== $result = $this->cache->get($cacheKey)) { @@ -92,7 +92,7 @@ public function getName(): string return sprintf('%s (cache)', $this->realProvider->getName()); } - public function __call($method, $args) + final public function __call($method, $args) { return call_user_func_array([$this->realProvider, $method], $args); } @@ -102,7 +102,7 @@ public function __call($method, $args) * * @return string */ - private function getCacheKey($query): string + protected function getCacheKey($query): string { // Include the major version number of the geocoder to avoid issues unserializing. return 'v4'.sha1((string) $query);