Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
55.00% |
11 / 20 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
| SentEmailData | |
55.00% |
11 / 20 |
|
66.67% |
2 / 3 |
3.82 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| fromRow | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
1 | |||
| toArray | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Domain\Notification\Data; |
| 6 | |
| 7 | use App\Support\Row; |
| 8 | |
| 9 | /** |
| 10 | * A single recorded outbound email, as shown in the in-app email history. |
| 11 | * |
| 12 | * For sensitive emails (e.g. password reset) bodyHtml/bodyText are null — only |
| 13 | * metadata is retained. See {@see \App\Domain\Notification\Service\RecordingEmailService}. |
| 14 | */ |
| 15 | final readonly class SentEmailData |
| 16 | { |
| 17 | public function __construct( |
| 18 | public ?int $sentEmailId = null, |
| 19 | public ?int $investorId = null, |
| 20 | public ?string $recipientEmail = null, |
| 21 | public ?string $subject = null, |
| 22 | public ?string $bodyHtml = null, |
| 23 | public ?string $bodyText = null, |
| 24 | public ?bool $isSensitive = null, |
| 25 | public ?string $sentAt = null, |
| 26 | ) {} |
| 27 | |
| 28 | /** |
| 29 | * @param array<mixed> $row |
| 30 | */ |
| 31 | public static function fromRow(array $row): self |
| 32 | { |
| 33 | return new self( |
| 34 | sentEmailId: Row::nullableInt($row, 'sentEmailId'), |
| 35 | investorId: Row::nullableInt($row, 'investorId'), |
| 36 | recipientEmail: Row::nullableString($row, 'recipientEmail'), |
| 37 | subject: Row::nullableString($row, 'subject'), |
| 38 | bodyHtml: Row::nullableString($row, 'bodyHtml'), |
| 39 | bodyText: Row::nullableString($row, 'bodyText'), |
| 40 | isSensitive: Row::nullableBool($row, 'isSensitive'), |
| 41 | sentAt: Row::nullableString($row, 'sentAt'), |
| 42 | ); |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * @return array<string, mixed> |
| 47 | */ |
| 48 | public function toArray(): array |
| 49 | { |
| 50 | return [ |
| 51 | 'sentEmailId' => $this->sentEmailId, |
| 52 | 'recipientEmail' => $this->recipientEmail, |
| 53 | 'subject' => $this->subject, |
| 54 | 'bodyHtml' => $this->bodyHtml, |
| 55 | 'bodyText' => $this->bodyText, |
| 56 | 'isSensitive' => $this->isSensitive, |
| 57 | 'sentAt' => $this->sentAt, |
| 58 | ]; |
| 59 | } |
| 60 | } |