25 lines
451 B
PHP
25 lines
451 B
PHP
<?php
|
|
|
|
namespace App\Flag;
|
|
|
|
use Predis\ClientInterface;
|
|
|
|
class FlagAccessor
|
|
{
|
|
public function __construct(
|
|
private readonly ClientInterface $redis
|
|
) {
|
|
}
|
|
|
|
public function isFlagEnabled(FlagEnum $flagName, bool $fallbackValue = false): bool
|
|
{
|
|
$flagValue = $this->redis->get($flagName->value);
|
|
|
|
if (null === $flagValue) {
|
|
return $fallbackValue;
|
|
}
|
|
|
|
return (bool) $flagValue;
|
|
}
|
|
}
|