Skip to content

Commit 6ad2c5d

Browse files
authored
Merge pull request #152 from bearsunday/mobile-detect
Update mobiledetect/mobiledetectlib dependency version and make it optional
2 parents 9ceeb86 + db655c5 commit 6ad2c5d

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

composer-require-checker.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"static", "self", "parent",
55
"array", "string", "int", "float", "bool", "iterable", "callable", "void", "object",
66
"Attribute", "Memcached", "Redis", "RedisException",
7-
"Doctrine\\Common\\Cache\\ArrayCache", "Doctrine\\Common\\Cache\\MemcachedCache", "Doctrine\\Common\\Cache\\RedisCache"
7+
"Doctrine\\Common\\Cache\\ArrayCache", "Doctrine\\Common\\Cache\\MemcachedCache", "Doctrine\\Common\\Cache\\RedisCache",
8+
"Detection\\MobileDetect"
89
]
910
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"bear/sunday": "^1.5",
1616
"doctrine/annotations": "^1.8 || ^2.0",
1717
"doctrine/cache": "^1.12 || ^2.0",
18-
"mobiledetect/mobiledetectlib": "^3.74",
1918
"psr/cache": "^1.0 || ^2.0 || ^3.0",
2019
"ray/aop": "^2.16",
2120
"ray/di": "^2.17.2",
@@ -28,6 +27,7 @@
2827
"bamarni/composer-bin-plugin": "^1.8",
2928
"koriym/attributes": "^1.0.1",
3029
"madapaja/twig-module": "^2.3",
30+
"mobiledetect/mobiledetectlib": "^3.74 || ^4.8",
3131
"phpunit/phpunit": "^9.5.28",
3232
"predis/predis": "^2.2",
3333
"symfony/process": "^4.3 || ^5.4 || ^6.1 || ^7.1",

src/MobileEtagModule.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44

55
namespace BEAR\QueryRepository;
66

7+
use Detection\MobileDetect;
8+
use LogicException;
79
use Ray\Di\AbstractModule;
810
use Ray\Di\Scope;
911

12+
use function class_exists;
13+
1014
/**
1115
* Provides EtagSetterInterface
1216
*
@@ -21,6 +25,10 @@ final class MobileEtagModule extends AbstractModule
2125
*/
2226
protected function configure(): void
2327
{
28+
if (! class_exists(MobileDetect::class)) {
29+
throw new LogicException('Install mobile-detect/mobiledetectlib'); // @codeCoverageIgnore
30+
}
31+
2432
$this->bind(EtagSetterInterface::class)->to(MobileEtagSetter::class)->in(Scope::SINGLETON);
2533
}
2634
}

0 commit comments

Comments
 (0)