Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
22 / 22
83.33% covered (warning)
83.33%
5 / 6
75.00% covered (warning)
75.00%
3 / 4
66.67% covered (warning)
66.67%
2 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
DoctrineNotificationLog
100.00% covered (success)
100.00%
22 / 22
83.33% covered (warning)
83.33%
5 / 6
75.00% covered (warning)
75.00%
3 / 4
100.00% covered (success)
100.00%
3 / 3
4.25
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 fromDomain
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 toDomain
100.00% covered (success)
100.00%
11 / 11
75.00% covered (warning)
75.00%
3 / 4
50.00% covered (danger)
50.00%
1 / 2
100.00% covered (success)
100.00%
1 / 1
2.50
1<?php
2
3namespace App\Notification\Infrastructure\Persistence\Doctrine\Entity;
4
5use App\Notification\Domain\Model\NotificationLog;
6use App\Notification\Domain\Model\NotificationStatus;
7use App\Notification\Domain\Model\NotificationType;
8use App\Shared\Domain\Model\EntityId;
9use Doctrine\ORM\Mapping as ORM;
10
11/**
12 * @author Wilhelm Zwertvaegher
13 */
14#[ORM\Entity]
15#[ORM\Table(name: "notifications")]
16class DoctrineNotificationLog
17{
18    #[ORM\Id, ORM\Column(type: "string", length: 36)]
19    private string $id;
20
21    #[ORM\Column(type: "string", length: 36)]
22    private string $identityId;
23
24    #[ORM\Column(type: "string", length: 36, nullable: true)]
25    private ?string $userId;
26
27    #[ORM\Column(type: "string", length: 36)]
28    private string $messageId;
29
30    #[ORM\Column(type: "string", enumType: NotificationType::class)]
31    private NotificationType $type;
32
33    #[ORM\Column(type: "string")]
34    private string $sender;
35
36    #[ORM\Column(type: "string", enumType: NotificationStatus::class)]
37    private NotificationStatus $status;
38
39    #[ORM\Column(type: "string")]
40    private string $statusMessage;
41
42    #[ORM\Column(type: 'datetime_immutable')]
43    private \DateTimeImmutable $createdAt;
44
45    public function __construct()
46    {
47    }
48
49
50    public function fromDomain(NotificationLog $notificationLog): DoctrineNotificationLog
51    {
52        $this->id = $notificationLog->getId();
53        $this->identityId = $notificationLog->getIdentityId();
54        $this->userId = $notificationLog->getUserId();
55        $this->messageId = $notificationLog->getMessageId();
56        $this->type = $notificationLog->getType();
57        $this->sender = $notificationLog->getSender();
58        $this->status = $notificationLog->getStatus();
59        $this->statusMessage = $notificationLog->getStatusMessage();
60        $this->createdAt = $notificationLog->getCreatedAt();
61        return $this;
62    }
63
64    public function toDomain(): NotificationLog
65    {
66        return new NotificationLog(
67            id: EntityId::fromString($this->id),
68            identityId: EntityId::fromString($this->identityId),
69            userId: $this->userId ? EntityId::fromString($this->userId) : null,
70            messageId: EntityId::fromString($this->messageId),
71            type: $this->type,
72            sender: $this->sender,
73            status: $this->status,
74            statusMessage: $this->statusMessage,
75            createdAt: $this->createdAt
76        );
77    }
78}