Skip to content

Commit 920c549

Browse files
Bugfix: Allow Injection of Any PSR Cache Interface (#966)
1 parent 8f54bd3 commit 920c549

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/MobileDetect.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
use Detection\Cache\CacheException;
3232
use Detection\Exception\MobileDetectException;
3333
use Psr\Cache\InvalidArgumentException;
34+
use Psr\SimpleCache\CacheInterface;
3435

3536
/**
3637
* Auto-generated isXXXX() magic methods.
@@ -231,7 +232,7 @@ class MobileDetect
231232
*
232233
* Replace this with your own implementation.
233234
*/
234-
protected Cache $cache;
235+
protected CacheInterface $cache;
235236

236237
/**
237238
* Stores the version number of the current release.
@@ -1028,7 +1029,7 @@ class MobileDetect
10281029
* Construct an instance of this class.
10291030
*/
10301031
public function __construct(
1031-
?Cache $cache = null,
1032+
?CacheInterface $cache = null,
10321033
array $config = [],
10331034
) {
10341035
// If no custom cache provided then use our own.
@@ -1508,7 +1509,7 @@ public function is(string $ruleName): bool
15081509
try {
15091510
$cacheKey = $this->createCacheKey($ruleName);
15101511
$cacheItem = $this->cache->get($cacheKey);
1511-
if (!is_null($cacheItem)) {
1512+
if ($cacheItem) {
15121513
return $cacheItem->get();
15131514
}
15141515

0 commit comments

Comments
 (0)