public function __construct( private array
$config,
private readonly StorageInterface
$storage,
private readonly SystemConfigService
$systemConfigService,
private readonly ?LockFactory
$lockFactory = null
) { } public function create(?string
$key = null
): LimiterInterface
{ if ($this->config
['enabled'
] === false
) { return new NoLimiter();
} $id =
$this->config
['id'
] . '-' .
(string) $key;
$lock =
$this->lockFactory ?
$this->lockFactory->
createLock($id) :
new NoLock();
if (isset($this->config
['reset'
]) && !
($this->config
['reset'
] instanceof \DateInterval
)) { $this->config
['reset'
] =
(new \
DateTimeImmutable())->
diff(new \
DateTimeImmutable('+' .
$this->config
['reset'
]));
} if ($this->config
['policy'
] === 'time_backoff' &&
isset($this->config
['limits'
]) &&
isset($this->config
['reset'
])) { /** @var list<TimeBackoffLimit> $limits */