throw new \
LogicException(sprintf('Cannot parse interval "%s", please use a valid unit as described on https://www.php.net/datetime.formats.relative.',
$m[1
]));
} };
$options ->
define('id'
)->
required() ->
define('policy'
) ->
required() ->
allowedValues('token_bucket', 'fixed_window', 'sliding_window', 'no_limit'
) ->
define('limit'
)->
allowedTypes('int'
) ->
define('interval'
)->
allowedTypes('string'
)->
normalize($intervalNormalizer) ->
define('rate'
) ->
default(function DOptionsResolver
$rate) use ($intervalNormalizer) { $rate ->
define('amount'
)->
allowedTypes('int'
)->
default(1
) ->
define('interval'
)->
allowedTypes('string'
)->
normalize($intervalNormalizer) ;
}) ->
normalize(function DOptions
$options,
$value) { if (!
isset($value['interval'
])) { return null;
}