Skip to content
docsv0.1.0

Event

Immutable fact appended to an {@see EventStoreInterface}'s log. A stream's state is never stored directly — it is always the fold of its `Event`s, so this VO is the only unit of truth an event store persists. `streamId` groups events into independent, individually replayable streams (a process instance, an aggregate, an entity id — any identifier the consumer chooses to partition its log by). `type` is a free-form name the consumer defines and interprets; the store itself never inspects it.

Event::__construct()

public function __construct(string $streamId, string $type, array $payload, int $seq):

Parameters

Parameters of __construct()
NameTypeDescription
$streamIdstringthe stream this event belongs to
$typestringthe event's name, defined and interpreted by the consumer
$payloadarray<string, mixed>data carried by this event
$seqintmonotonic position of this event within its event store

Event::toArray()

public function toArray(): array

Projects this event into a plain array suitable for JSON encoding (JSONL round-trip).

Event::fromArray()

public static function fromArray(array $row): self

Reconstructs an event from the array shape produced by {@see self::toArray()}.

Parameters

Parameters of fromArray()
NameTypeDescription
$rowarray{stream_id: string, type: string, payload: array<string, mixed>, seq: int}