Skip to content

Commit 3ecbeb4

Browse files
committed
fix bug where if hash number is 100, fails to match variant that is 100
1 parent b8d5558 commit 3ecbeb4

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Diff for: src/Configurations/Config.php

+9-5
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,16 @@ public function pickVariantOutOfHat(string $id): string
3535
{
3636
$hashOrRandomNumber = $this->bucketing->strToIntHash($id);
3737

38-
$variant = key(array_filter(
39-
$this->variantIntegerRanges,
40-
fn (int $variantRange): bool => $hashOrRandomNumber < $variantRange
41-
));
38+
foreach ($this->variantIntegerRanges as $variant => $variantRange) {
39+
if ($hashOrRandomNumber < $variantRange) {
40+
return $variant;
41+
}
42+
if ($hashOrRandomNumber === 100 && $variantRange === 100) {
43+
return $variant;
44+
}
45+
}
4246

43-
return $variant ?? '';
47+
return '';
4448
}
4549

4650
/**

0 commit comments

Comments
 (0)