/**
* @return array<int>
*/
function exponentialBackoff(
int $times,
int $delay,
float $min = 0.9,
float $max = 1.1
): array {
$backoff = [];
for ($i = 0; $i < $times; $i++) {
$backoff[] = (int) ($delay * ($min + mt_rand() / mt_getrandmax() * ($max - $min))) << $i;
}
return $backoff;
}
/**
* @return array<int>
*/
function exponentialBackoff(
int $times,
int $delay,
float $min = 0.9,
float $max = 1.1
): array {
$backoff = [];
for ($i = 0; $i < $times; $i++) {
$backoff[] = (int) ($delay * ($min + mt_rand() / mt_getrandmax() * ($max - $min))) << $i;
}
return $backoff;
}