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. `recordedAt` is the wall-clock observation made by the process constructing the event. It is not a verified occurrence time or a duration: its trust is exactly the trust placed in that process and its clock. A `null` value is reserved for records written before this observation existed; readers must preserve that gap rather than manufacture a time from file metadata or payload contents.
Event::__construct()
public function __construct(string $streamId, string $type, array $payload, int $seq, ?DateTimeImmutable $recordedAt = new DateTimeImmutable()):Parameters
| Name | Type | Description |
|---|---|---|
| $streamId | string | the stream this event belongs to |
| $type | string | the event's name, defined and interpreted by the consumer |
| $payload | array<string, mixed> | data carried by this event |
| $seq | int | monotonic position of this event within its event store |
| $recordedAt | ?\DateTimeImmutable | wall-clock observation by the constructing process; `null` means the record predates this field |
Event::toArray()
public function toArray(): arrayProjects this event into a plain array suitable for JSON encoding (JSONL round-trip).
Event::fromArray()
public static function fromArray(array $row): selfReconstructs an event from the array shape produced by {@see self::toArray()}.
Parameters
| Name | Type | Description |
|---|---|---|
| $row | array{stream_id: string, type: string, payload: array<string, mixed>, seq: int, recorded_at?: ?string} |