Files
hydra-sql/src/Flag/FlagAccessor.php
Gauthier DUPONT 12523398f6
Some checks are pending
Cadoles/hydra-sql/pipeline/pr-develop Build started...
feat(altcha): add altcha validation layer to login
2025-04-10 16:01:22 +02:00

27 lines
523 B
PHP

<?php
namespace App\Flag;
use Psr\Cache\CacheItemPoolInterface;
class FlagAccessor
{
public const FLAG_VALUE = 'flagValue';
public function __construct(
private readonly CacheItemPoolInterface $cache
) {
}
public function isFlagEnabled(FlagEnum $flagName, bool $fallbackValue = false): bool
{
$flagValue = $this->cache->getItem($flagName->value)->get();
if (null === $flagValue) {
return $fallbackValue;
}
return (bool) $flagValue;
}
}