Skip to content

Commit

Permalink
Add validation to ensure FastlyPurgeModule is installed
Browse files Browse the repository at this point in the history
Check if the FastlyPurgeModule class exists during construction and throw a LogicException if it is missing. This prevents misconfigurations and ensures the required dependency is installed.
  • Loading branch information
koriym committed Jan 9, 2025
1 parent a3d0067 commit 2100303
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Cdn/FastlyModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
}
}

/**
Expand Down

0 comments on commit 2100303

Please sign in to comment.