Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: Allow Injection of Any PSR Cache Interface #966

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/MobileDetect.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use Detection\Cache\CacheException;
use Detection\Exception\MobileDetectException;
use Psr\Cache\InvalidArgumentException;
use Psr\SimpleCache\CacheInterface;

/**
* Auto-generated isXXXX() magic methods.
Expand Down Expand Up @@ -231,7 +232,7 @@ class MobileDetect
*
* Replace this with your own implementation.
*/
protected Cache $cache;
protected CacheInterface $cache;

/**
* Stores the version number of the current release.
Expand Down Expand Up @@ -1028,7 +1029,7 @@ class MobileDetect
* Construct an instance of this class.
*/
public function __construct(
?Cache $cache = null,
?CacheInterface $cache = null,
array $config = [],
) {
// If no custom cache provided then use our own.
Expand Down Expand Up @@ -1508,7 +1509,7 @@ public function is(string $ruleName): bool
try {
$cacheKey = $this->createCacheKey($ruleName);
$cacheItem = $this->cache->get($cacheKey);
if (!is_null($cacheItem)) {
if ($cacheItem) {
return $cacheItem->get();
}

Expand Down
Loading