diff --git a/composer-require-checker.json b/composer-require-checker.json index c553a5be..fcb00648 100644 --- a/composer-require-checker.json +++ b/composer-require-checker.json @@ -5,6 +5,7 @@ "array", "string", "int", "float", "bool", "iterable", "callable", "void", "object", "Attribute", "Memcached", "Redis", "RedisException", "Doctrine\\Common\\Cache\\ArrayCache", "Doctrine\\Common\\Cache\\MemcachedCache", "Doctrine\\Common\\Cache\\RedisCache", + "BEAR\\FastlyModule\\FastlyCachePurgerInterface", "BEAR\\FastlyModule\\FastlyPurgeModule", "Detection\\MobileDetect" ] } diff --git a/composer.json b/composer.json index 9d8ec013..db6c22f7 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,6 @@ ], "require": { "php": "^8.1", - "bear/fastly-module": "^1.0", "bear/resource": "^1.16.1", "bear/sunday": "^1.5", "doctrine/annotations": "^1.8 || ^2.0", @@ -24,6 +23,7 @@ }, "require-dev": { "ext-redis": "*", + "bear/fastly-module": "^1.0", "bamarni/composer-bin-plugin": "^1.8", "koriym/attributes": "^1.0.1", "madapaja/twig-module": "^2.3", diff --git a/src/Cdn/FastlyModule.php b/src/Cdn/FastlyModule.php index 65579176..aef8c079 100644 --- a/src/Cdn/FastlyModule.php +++ b/src/Cdn/FastlyModule.php @@ -7,8 +7,11 @@ use BEAR\FastlyModule\FastlyPurgeModule; use BEAR\QueryRepository\CdnCacheControlHeaderSetterInterface; use BEAR\QueryRepository\PurgerInterface; +use LogicException; use Ray\Di\AbstractModule; +use function class_exists; + final class FastlyModule extends AbstractModule { public function __construct( @@ -17,6 +20,10 @@ public function __construct( AbstractModule|null $module = null, ) { parent::__construct($module); + + if (! class_exists(FastlyPurgeModule::class)) { + throw new LogicException('Install bear/fastly-module'); // @codeCoverageIgnore + } } /** diff --git a/src/QueryRepository.php b/src/QueryRepository.php index c948ef81..af713c53 100644 --- a/src/QueryRepository.php +++ b/src/QueryRepository.php @@ -64,7 +64,7 @@ public function get(AbstractUri $uri): ResourceState|null return null; } - $state->headers[Header::AGE] = (string) (time() - strtotime($state->headers[Header::LAST_MODIFIED])); + $state->headers[Header::AGE] = (string) (time() - (int) strtotime($state->headers[Header::LAST_MODIFIED])); return $state; } @@ -113,6 +113,6 @@ private function getExpiryAtSec(ResourceObject $ro, Cacheable $cacheable): int /** @var string $expiryAt */ $expiryAt = $ro->body[$cacheable->expiryAt]; - return strtotime($expiryAt) - time(); + return (int) strtotime($expiryAt) - time(); } }