Skip to content

AssignmentReceipt ​

Rasuvaeff\Yii3AbTesting\AssignmentReceipt

Class · rasuvaeff/yii3-ab-testing · Source

Proof of an exposure, small enough to travel in a cookie or session so a conversion in a later request can be attributed without resolving the assignment again (which could return a different variant after a reweight).

Deliberately carries no environment or dimensions: receipts are stored in size-capped cookies, and a conversion records the context of its own request anyway. The link back to the exposure is exposureEventId.

Constructor ​

php
new AssignmentReceipt(
    string $exposureEventId,
    DateTimeImmutable $occurredAt,
    string $experiment,
    string $variant,
    string $subjectId,
    DecisionReason $reason,
    AssignmentSource $source,
    ?string $experimentRevision = null,
)

Properties ​

PropertyTypeReadonlyDescription
exposureEventIdstringyes
occurredAtDateTimeImmutableyes
experimentstringyes
variantstringyes
subjectIdstringyes
experimentRevision?stringyes
reasonDecisionReasonyes
sourceAssignmentSourceyes

Methods ​

toArray() ​

php
toArray(): array

fromArray() ​

php
static fromArray(array $data): self

Rebuilds a receipt from toArray() output.

The input is transport data — a cookie value is attacker-controlled even when signed — so every field is re-validated rather than trusted.