Skip to content

StickyAssignmentResolver ​

Rasuvaeff\Yii3AbTestingWeb\StickyAssignmentResolver

Class · rasuvaeff/yii3-ab-testing-web · Source · implements AssignmentResolver

Resolves an assignment with stickiness: a previously stored variant wins over a fresh deterministic assignment, so a subject keeps their variant across requests. The wrapped core AssignmentResolver remains side-effect free.

Rules:

  • A disabled experiment returns its fallback and never reads or writes the store, so the kill switch always takes effect.
  • In an enabled experiment, a forced variant bypasses targeting and the store (QA override).
  • A targeting mismatch returns the core fallback and never reads or writes the store, so a previous sticky assignment cannot bypass targeting.
  • Configuration-aware stores reuse a variant only for the same experiment configuration id. Legacy stores retain their original behavior.
  • Fallback results are not stored.
  • An assignment served from the store carries isSticky = true.

Constructor ​

php
new StickyAssignmentResolver(AssignmentResolver $resolver, AssignmentStore $store)

Methods ​

resolve() ​

php
resolve(
    string $experiment,
    string $subjectId,
    ?string $forcedVariant = null,
    ?AssignmentContext $context = null,
): Assignment