$recipients */ public function __construct( private readonly string $subject, private readonly string $message, private readonly array $recipients, ) { } public static function fromRecipients(string $subject, string $message, TeamerMailingRecipientsDto $recipients): self { $snapshot = []; foreach ($recipients->getEligible() as $recipient) { // resolveRecipients() already guaranteed the address, this only narrows the type if (null === $email = $recipient->getEmail()) { continue; } $snapshot[] = [ 'email' => $email, 'firstName' => $recipient->getFirstName(), 'lastName' => $recipient->getLastName(), 'fullName' => $recipient->getFullName(), ]; } return new self($subject, $message, $snapshot); } public function getSubject(): string { return $this->subject; } public function getMessage(): string { return $this->message; } /** * @return array */ public function getRecipients(): array { return $this->recipients; } public function getRecipientCount(): int { return count($this->recipients); } }