Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
11 / 11 |
|
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| NotificationLogService | |
100.00% |
11 / 11 |
|
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| save | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| createFromNotification | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Service\Data; |
| 4 | |
| 5 | use App\Entity\Notification; |
| 6 | use App\Entity\NotificationLog; |
| 7 | use App\Service\Notification\Dispatcher\NotificationDispatchResult; |
| 8 | use Doctrine\ORM\EntityManagerInterface; |
| 9 | use Psr\Clock\ClockInterface; |
| 10 | |
| 11 | /** |
| 12 | * @author Wilhelm Zwertvaegher |
| 13 | */ |
| 14 | readonly class NotificationLogService implements NotificationLogServiceInterface |
| 15 | { |
| 16 | public function __construct( |
| 17 | private EntityManagerInterface $entityManager, |
| 18 | private ClockInterface $clock) |
| 19 | { |
| 20 | } |
| 21 | |
| 22 | public function save(NotificationLog $notificationLog): void |
| 23 | { |
| 24 | $this->entityManager->persist($notificationLog); |
| 25 | } |
| 26 | |
| 27 | public function createFromNotification(Notification $notification, NotificationDispatchResult $result): NotificationLog |
| 28 | { |
| 29 | $notificationLog = new NotificationLog( |
| 30 | notification: $notification, |
| 31 | sender: $result->getSender(), |
| 32 | status: $result->getStatus(), |
| 33 | statusMessage: $result->getMessage(), |
| 34 | createdAt: $this->clock->now() |
| 35 | ); |
| 36 | $this->save($notificationLog); |
| 37 | |
| 38 | return $notificationLog; |
| 39 | } |
| 40 | } |