Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
12 / 12 |
|
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| DefaultNotificationLogService | |
100.00% |
12 / 12 |
|
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| createFromNotification | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Notification\Domain\Service; |
| 4 | |
| 5 | use App\Notification\Domain\Model\Notification; |
| 6 | use App\Notification\Domain\Model\NotificationLog; |
| 7 | use App\Notification\Domain\Model\NotificationDispatchResult; |
| 8 | use App\Shared\Domain\Model\EntityId; |
| 9 | use App\Shared\Domain\Port\Driven\Clock; |
| 10 | |
| 11 | /** |
| 12 | * @author Wilhelm Zwertvaegher |
| 13 | */ |
| 14 | class DefaultNotificationLogService implements NotificationLogService |
| 15 | { |
| 16 | public function __construct(private readonly Clock $clock) |
| 17 | { |
| 18 | } |
| 19 | |
| 20 | public function createFromNotification(Notification $notification, NotificationDispatchResult $result): NotificationLog |
| 21 | { |
| 22 | return NotificationLog::create( |
| 23 | EntityId::generate(), |
| 24 | EntityId::fromString($notification->getIdentityInfo()->getIdentityId()), |
| 25 | null, |
| 26 | EntityId::fromString($notification->getMessageId()), |
| 27 | $notification->getType(), |
| 28 | $result->getSender(), |
| 29 | $result->getStatus(), |
| 30 | $result->getMessage(), |
| 31 | $this->clock->getNow() |
| 32 | ); |
| 33 | } |
| 34 | } |