Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
88.89% covered (warning)
88.89%
8 / 9
85.71% covered (warning)
85.71%
6 / 7
85.71% covered (warning)
85.71%
6 / 7
85.71% covered (warning)
85.71%
6 / 7
CRAP
0.00% covered (danger)
0.00%
0 / 1
DoctrineNotificationLogRepository
88.89% covered (warning)
88.89%
8 / 9
85.71% covered (warning)
85.71%
6 / 7
85.71% covered (warning)
85.71%
6 / 7
85.71% covered (warning)
85.71%
6 / 7
7.14
0.00% covered (danger)
0.00%
0 / 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
 save
100.00% covered (success)
100.00%
3 / 3
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
 findByMessageId
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
 findByMessageIdAndSender
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 findByMessageIdAndSenderAndStatus
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
 findByMessageIdAndStatus
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
 hasSuccess
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
1<?php
2
3namespace App\Notification\Infrastructure\Persistence\Doctrine\Repository;
4
5use App\Notification\Domain\Model\NotificationLog;
6use App\Notification\Domain\Model\NotificationStatus;
7use App\Notification\Domain\Port\Driven\NotificationLogRepository;
8use App\Notification\Infrastructure\Persistence\Doctrine\Entity\DoctrineNotificationLog;
9use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
10use Doctrine\ORM\EntityManagerInterface;
11use Doctrine\Persistence\ManagerRegistry;
12
13/**
14 * @author Wilhelm Zwertvaegher
15 * @extends ServiceEntityRepository<DoctrineNotificationLog>
16 */
17class DoctrineNotificationLogRepository extends ServiceEntityRepository implements NotificationLogRepository
18{
19
20    public function __construct(ManagerRegistry $managerRegistry, private readonly EntityManagerInterface $entityManager)
21    {
22        parent::__construct($managerRegistry, DoctrineNotificationLog::class);
23    }
24
25    public function save(NotificationLog $notificationLog): void
26    {
27        // reloading to get an attached entity if it already exists
28        $doctrineEntity = $this->find($notificationLog->getId()) ?? new DoctrineNotificationLog();
29        $doctrineEntity->fromDomain($notificationLog);
30        $this->entityManager->persist($doctrineEntity);
31    }
32
33    /**
34     * @param string $messageId
35     * @return array<NotificationLog>
36     */
37    public function findByMessageId(string $messageId): array
38    {
39        return array_map(fn(DoctrineNotificationLog $log) => $log->toDomain(), $this->findBy(['messageId' => $messageId]));
40    }
41
42    /**
43     * @param string $messageId
44     * @param string $sender
45     * @return array<NotificationLog>
46     */
47    public function findByMessageIdAndSender(string $messageId, string $sender): array
48    {
49        return array_map(fn(DoctrineNotificationLog $log) => $log->toDomain(), $this->findBy(['messageId' => $messageId, 'sender' => $sender]));
50    }
51
52    /**
53     * @param string $messageId
54     * @param string $sender
55     * @param NotificationStatus $status
56     * @return array<NotificationLog>
57     */
58    public function findByMessageIdAndSenderAndStatus(string $messageId, string $sender, NotificationStatus $status): array
59    {
60        return array_map(fn(DoctrineNotificationLog $log) => $log->toDomain(), $this->findBy(['messageId' => $messageId, 'sender' => $sender, 'status' => $status]));
61    }
62
63    /**
64     * @param string $messageId
65     * @param NotificationStatus $status
66     * @return array<NotificationLog>
67     */
68    public function findByMessageIdAndStatus(string $messageId, NotificationStatus $status): array
69    {
70        return array_map(fn(DoctrineNotificationLog $log) => $log->toDomain(), $this->findBy(['messageId' => $messageId, 'status' => $status]));
71    }
72
73    public function hasSuccess(string $messageId, string $sender): bool
74    {
75        return count($this->findByMessageIdAndSenderAndStatus($messageId, $sender, NotificationStatus::SENT)) > 0;
76    }
77}

Paths

Below are the source code lines that represent each code path as identified by Xdebug. Please note a path is not necessarily coterminous with a line, a line may contain multiple paths and therefore show up more than once. Please also be aware that some paths may include implicit rather than explicit branches, e.g. an if statement always has an else as part of its logical flow even if you didn't write one.

DoctrineNotificationLogRepository->__construct
20    public function __construct(ManagerRegistry $managerRegistry, private readonly EntityManagerInterface $entityManager)
21    {
22        parent::__construct($managerRegistry, DoctrineNotificationLog::class);
23    }
DoctrineNotificationLogRepository->findByMessageId
37    public function findByMessageId(string $messageId): array
38    {
39        return array_map(fn(DoctrineNotificationLog $log) => $log->toDomain(), $this->findBy(['messageId' => $messageId]));
40    }
DoctrineNotificationLogRepository->findByMessageIdAndSender
47    public function findByMessageIdAndSender(string $messageId, string $sender): array
48    {
49        return array_map(fn(DoctrineNotificationLog $log) => $log->toDomain(), $this->findBy(['messageId' => $messageId, 'sender' => $sender]));
50    }
DoctrineNotificationLogRepository->findByMessageIdAndSenderAndStatus
58    public function findByMessageIdAndSenderAndStatus(string $messageId, string $sender, NotificationStatus $status): array
59    {
60        return array_map(fn(DoctrineNotificationLog $log) => $log->toDomain(), $this->findBy(['messageId' => $messageId, 'sender' => $sender, 'status' => $status]));
61    }
DoctrineNotificationLogRepository->findByMessageIdAndStatus
68    public function findByMessageIdAndStatus(string $messageId, NotificationStatus $status): array
69    {
70        return array_map(fn(DoctrineNotificationLog $log) => $log->toDomain(), $this->findBy(['messageId' => $messageId, 'status' => $status]));
71    }
DoctrineNotificationLogRepository->hasSuccess
73    public function hasSuccess(string $messageId, string $sender): bool
74    {
75        return count($this->findByMessageIdAndSenderAndStatus($messageId, $sender, NotificationStatus::SENT)) > 0;
76    }
DoctrineNotificationLogRepository->save
25    public function save(NotificationLog $notificationLog): void
26    {
27        // reloading to get an attached entity if it already exists
28        $doctrineEntity = $this->find($notificationLog->getId()) ?? new DoctrineNotificationLog();
29        $doctrineEntity->fromDomain($notificationLog);
30        $this->entityManager->persist($doctrineEntity);
31    }
{closure:/home/runner/work/my-lego-collection/my-lego-collection/back/src/Notification/Infrastructure/Persistence/Doctrine/Repository/DoctrineNotificationLogRepository.php:39-39}
39        return array_map(fn(DoctrineNotificationLog $log) => $log->toDomain(), $this->findBy(['messageId' => $messageId]));
{closure:/home/runner/work/my-lego-collection/my-lego-collection/back/src/Notification/Infrastructure/Persistence/Doctrine/Repository/DoctrineNotificationLogRepository.php:49-49}
49        return array_map(fn(DoctrineNotificationLog $log) => $log->toDomain(), $this->findBy(['messageId' => $messageId, 'sender' => $sender]));
{closure:/home/runner/work/my-lego-collection/my-lego-collection/back/src/Notification/Infrastructure/Persistence/Doctrine/Repository/DoctrineNotificationLogRepository.php:60-60}
60        return array_map(fn(DoctrineNotificationLog $log) => $log->toDomain(), $this->findBy(['messageId' => $messageId, 'sender' => $sender, 'status' => $status]));
{closure:/home/runner/work/my-lego-collection/my-lego-collection/back/src/Notification/Infrastructure/Persistence/Doctrine/Repository/DoctrineNotificationLogRepository.php:70-70}
70        return array_map(fn(DoctrineNotificationLog $log) => $log->toDomain(), $this->findBy(['messageId' => $messageId, 'status' => $status]));
{main}
3namespace App\Notification\Infrastructure\Persistence\Doctrine\Repository;
4
5use App\Notification\Domain\Model\NotificationLog;
6use App\Notification\Domain\Model\NotificationStatus;
7use App\Notification\Domain\Port\Driven\NotificationLogRepository;
8use App\Notification\Infrastructure\Persistence\Doctrine\Entity\DoctrineNotificationLog;
9use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
10use Doctrine\ORM\EntityManagerInterface;
11use Doctrine\Persistence\ManagerRegistry;
12
13/**
14 * @author Wilhelm Zwertvaegher
15 * @extends ServiceEntityRepository<DoctrineNotificationLog>
16 */
17class DoctrineNotificationLogRepository extends ServiceEntityRepository implements NotificationLogRepository
18{
19
20    public function __construct(ManagerRegistry $managerRegistry, private readonly EntityManagerInterface $entityManager)
21    {
22        parent::__construct($managerRegistry, DoctrineNotificationLog::class);
23    }
24
25    public function save(NotificationLog $notificationLog): void
26    {
27        // reloading to get an attached entity if it already exists
28        $doctrineEntity = $this->find($notificationLog->getId()) ?? new DoctrineNotificationLog();
29        $doctrineEntity->fromDomain($notificationLog);
30        $this->entityManager->persist($doctrineEntity);
31    }
32
33    /**
34     * @param string $messageId
35     * @return array<NotificationLog>
36     */
37    public function findByMessageId(string $messageId): array
38    {
39        return array_map(fn(DoctrineNotificationLog $log) => $log->toDomain(), $this->findBy(['messageId' => $messageId]));
40    }
41
42    /**
43     * @param string $messageId
44     * @param string $sender
45     * @return array<NotificationLog>
46     */
47    public function findByMessageIdAndSender(string $messageId, string $sender): array
48    {
49        return array_map(fn(DoctrineNotificationLog $log) => $log->toDomain(), $this->findBy(['messageId' => $messageId, 'sender' => $sender]));
50    }
51
52    /**
53     * @param string $messageId
54     * @param string $sender
55     * @param NotificationStatus $status
56     * @return array<NotificationLog>
57     */
58    public function findByMessageIdAndSenderAndStatus(string $messageId, string $sender, NotificationStatus $status): array
59    {
60        return array_map(fn(DoctrineNotificationLog $log) => $log->toDomain(), $this->findBy(['messageId' => $messageId, 'sender' => $sender, 'status' => $status]));
61    }
62
63    /**
64     * @param string $messageId
65     * @param NotificationStatus $status
66     * @return array<NotificationLog>
67     */
68    public function findByMessageIdAndStatus(string $messageId, NotificationStatus $status): array
69    {
70        return array_map(fn(DoctrineNotificationLog $log) => $log->toDomain(), $this->findBy(['messageId' => $messageId, 'status' => $status]));
71    }
72
73    public function hasSuccess(string $messageId, string $sender): bool
74    {
75        return count($this->findByMessageIdAndSenderAndStatus($messageId, $sender, NotificationStatus::SENT)) > 0;
76    }