Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
81.25% |
13 / 16 |
|
91.67% |
11 / 12 |
|
91.67% |
11 / 12 |
|
91.67% |
11 / 12 |
CRAP | |
0.00% |
0 / 1 |
| NotificationLog | |
81.25% |
13 / 16 |
|
91.67% |
11 / 12 |
|
91.67% |
11 / 12 |
|
91.67% |
11 / 12 |
12.08 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| create | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| pullEvents | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getIdentityId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getUserId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getMessageId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getType | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getSender | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getStatus | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getStatusMessage | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getCreatedAt | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Notification\Domain\Model; |
| 4 | |
| 5 | use App\Notification\Domain\Event\NotificationLogCreatedEvent; |
| 6 | use App\Shared\Domain\Event\DomainEvent; |
| 7 | use App\Shared\Domain\Model\EntityId; |
| 8 | use App\Shared\Domain\Model\ProducesDomainEvents; |
| 9 | |
| 10 | /** |
| 11 | * @author Wilhelm Zwertvaegher |
| 12 | */ |
| 13 | final class NotificationLog implements ProducesDomainEvents |
| 14 | { |
| 15 | /** |
| 16 | * @var array<DomainEvent> |
| 17 | */ |
| 18 | private array $events = []; |
| 19 | |
| 20 | public function __construct( |
| 21 | private readonly EntityId $id, |
| 22 | private readonly EntityId $identityId, |
| 23 | private readonly ?EntityId $userId, |
| 24 | private readonly EntityId $messageId, |
| 25 | private readonly NotificationType $type, |
| 26 | private string $sender, |
| 27 | private readonly NotificationStatus $status, |
| 28 | private readonly string $statusMessage, |
| 29 | private readonly \DateTimeImmutable $createdAt |
| 30 | ) { |
| 31 | } |
| 32 | |
| 33 | public static function create( |
| 34 | EntityId $id, |
| 35 | EntityId $identityId, |
| 36 | ?EntityId $userId, |
| 37 | EntityId $messageId, |
| 38 | NotificationType $type, |
| 39 | string $sender, |
| 40 | NotificationStatus $status, |
| 41 | string $statusMessage, |
| 42 | \DateTimeImmutable $createdAt, |
| 43 | ): self { |
| 44 | $newNotificationLog = new self($id, $identityId, $userId, $messageId, $type, $sender, $status, $statusMessage, $createdAt); |
| 45 | $newNotificationLog->events = [new NotificationLogCreatedEvent($newNotificationLog)]; |
| 46 | return $newNotificationLog; |
| 47 | } |
| 48 | |
| 49 | public function pullEvents(): array |
| 50 | { |
| 51 | $events = $this->events; |
| 52 | $this->events = []; |
| 53 | return $events; |
| 54 | } |
| 55 | |
| 56 | public function getId(): EntityId |
| 57 | { |
| 58 | return $this->id; |
| 59 | } |
| 60 | |
| 61 | public function getIdentityId(): EntityId |
| 62 | { |
| 63 | return $this->identityId; |
| 64 | } |
| 65 | |
| 66 | public function getUserId(): ?EntityId |
| 67 | { |
| 68 | return $this->userId; |
| 69 | } |
| 70 | |
| 71 | public function getMessageId(): EntityId |
| 72 | { |
| 73 | return $this->messageId; |
| 74 | } |
| 75 | |
| 76 | public function getType(): NotificationType |
| 77 | { |
| 78 | return $this->type; |
| 79 | } |
| 80 | |
| 81 | public function getSender(): string |
| 82 | { |
| 83 | return $this->sender; |
| 84 | } |
| 85 | |
| 86 | public function getStatus(): NotificationStatus |
| 87 | { |
| 88 | return $this->status; |
| 89 | } |
| 90 | |
| 91 | public function getStatusMessage(): string |
| 92 | { |
| 93 | return $this->statusMessage; |
| 94 | } |
| 95 | |
| 96 | public function getCreatedAt(): \DateTimeImmutable |
| 97 | { |
| 98 | return $this->createdAt; |
| 99 | } |
| 100 | } |