Skip to content

WeightedHashAssignmentStrategy ​

Rasuvaeff\Yii3AbTesting\WeightedHashAssignmentStrategy

Class · rasuvaeff/yii3-ab-testing · Source · implements AssignmentStrategy

Deterministic weighted assignment: sha256(salt . ':' . subjectId), first 8 hex digits → 32-bit bucket, modulo total weight. Requires 64-bit PHP — the bucket value exceeds PHP_INT_MAX on 32-bit builds.

Methods ​

assign() ​

php
assign(
    string $salt,
    string $subjectId,
    array $variants,
): string