Assignment
Rasuvaeff\Yii3AbTesting\Assignment
Class · rasuvaeff/yii3-ab-testing · Source
The outcome of resolving a subject into a variant.
Two independent axes describe it: DecisionReason says why this variant rather than the hash bucket, AssignmentSource says where the value came from. They replace the four overlapping booleans of v1, which could not express a sticky-served forced variant and, worse, could not tell a disabled experiment apart from a targeting miss once serialized.
Constructor
php
new Assignment(
string $experiment,
string $variant,
string $subjectId,
DecisionReason $reason = DecisionReason::Assigned,
AssignmentSource $source = AssignmentSource::Computed,
?AssignmentContext $context = null,
?string $configurationId = null,
)Properties
| Property | Type | Readonly | Description |
|---|---|---|---|
experiment | string | yes | |
variant | string | yes | |
subjectId | string | yes | |
reason | DecisionReason | yes | |
source | AssignmentSource | yes | |
context | ?AssignmentContext | yes | |
configurationId | ?string | yes |
Methods
isVariant()
php
isVariant(string $variant): boolisFallback()
php
isFallback(): boolServed the fallback variant, for either of the two reasons.
isForced()
php
isForced(): boolOverridden explicitly, bypassing targeting and any store.
isTargetingMismatch()
php
isTargetingMismatch(): boolFell back because the targeting rules did not match the context.
isSticky()
php
isSticky(): boolReplayed from an AssignmentStore rather than computed.