Skip to content
PHP Ecosystem
Explore

MailSnapshot

API reference › Debug Core › Panel › Mail › MailSnapshot

final readonly classPHPForge\Debug\Panel\Mail\MailSnapshot
ImplementsPHPForge\Debug\Storage\PanelSnapshot
Sourcesrc/Panel/Mail/MailSnapshot.php

Canonical Mail panel snapshot holding the captured messages in their typed form.

MethodDescriptionDefined by
__construct()Creates a mail snapshot from captured messages.MailSnapshot
capture() staticNarrows the captured EVENT_AFTER_SEND payloads into typed messages.MailSnapshot
entries()Returns the captured messages.MailSnapshot
fromArray() staticNarrows the persisted mail payload into a typed snapshot.MailSnapshot
jsonSerialize()Serializes the snapshot into its persisted payload.MailSnapshot
public function __construct(list<PHPForge\Debug\Panel\Mail\MailEntry> $entries)

Creates a mail snapshot from captured messages.

Parameters

ParameterTypeDescription
$entrieslist<MailEntry>Captured messages in send order.
public static function capture(array<array-key, mixed> $messages): self

Narrows the captured EVENT_AFTER_SEND payloads into typed messages.

Parameters

ParameterTypeDescription
$messagesarray<array-key, mixed>Captured payloads in send order; non-array entries are dropped.

Returns

self: Snapshot carrying the typed messages.

public function entries(): list<PHPForge\Debug\Panel\Mail\MailEntry>

Returns the captured messages.

Returns

list<MailEntry>: Captured messages in send order.

public static function fromArray(mixed $data, string $path): self

Narrows the persisted mail payload into a typed snapshot.

Parameters

ParameterTypeDescription
$datamixedPersisted payload, expected to be an object carrying an entries list.
$pathstringJSON path of the payload, used to report a malformed capture.

Returns

self: Snapshot carrying the persisted messages.

public function jsonSerialize(): array<string, mixed>

Serializes the snapshot into its persisted payload.

Returns

array<string, mixed>: Payload carrying the messages under the entries key.