Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
NotificationCommandHandler
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
3
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
 __invoke
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3namespace App\Notification\Application\Handler;
4
5use App\Notification\Domain\Port\Driven\NotificationDispatcher;
6use App\Notification\Domain\Service\NotificationFactory;
7use App\Notification\Domain\Port\Driven\NotificationLogRepository;
8use App\Notification\Domain\Service\NotificationLogService;
9use App\Shared\Domain\Port\Driven\TransactionProvider;
10use MyLegoCollection\SharedContracts\Command\Command;
11
12/**
13 * @author Wilhelm Zwertvaegher
14 */
15readonly class NotificationCommandHandler
16{
17    public function __construct(
18        private NotificationFactory       $notificationFactory,
19        private NotificationDispatcher    $notificationDispatcher,
20        private NotificationLogService    $notificationLogService,
21        private NotificationLogRepository $notificationLogRepository,
22        private TransactionProvider       $transactionProvider
23    ) {
24    }
25    public function __invoke(Command $command): void
26    {
27        // create notification to be sent
28        $notification = $this->notificationFactory->createNotification($command);
29
30        // pass to dispatcher
31        $results = $this->notificationDispatcher->dispatch($notification);
32
33        $this->transactionProvider->transactional(function () use ($notification, $results) {
34            // save logs for the notification
35            foreach ($results as $result) {
36                $this->notificationLogRepository->save(
37                    $this->notificationLogService->createFromNotification(
38                        $notification,
39                        $result
40                    )
41                );
42            }
43        });
44    }
45}

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.

NotificationCommandHandler->__construct
17    public function __construct(
18        private NotificationFactory       $notificationFactory,
19        private NotificationDispatcher    $notificationDispatcher,
20        private NotificationLogService    $notificationLogService,
21        private NotificationLogRepository $notificationLogRepository,
22        private TransactionProvider       $transactionProvider
23    ) {
24    }
NotificationCommandHandler->__invoke
25    public function __invoke(Command $command): void
26    {
27        // create notification to be sent
28        $notification = $this->notificationFactory->createNotification($command);
29
30        // pass to dispatcher
31        $results = $this->notificationDispatcher->dispatch($notification);
32
33        $this->transactionProvider->transactional(function () use ($notification, $results) {
34            // save logs for the notification
35            foreach ($results as $result) {
36                $this->notificationLogRepository->save(
37                    $this->notificationLogService->createFromNotification(
38                        $notification,
39                        $result
40                    )
41                );
42            }
43        });
44    }
{closure:/home/runner/work/my-lego-collection/my-lego-collection/back/src/Notification/Application/Handler/NotificationCommandHandler.php:33-43}
33        $this->transactionProvider->transactional(function () use ($notification, $results) {
34            // save logs for the notification
35            foreach ($results as $result) {
 
35            foreach ($results as $result) {
 
35            foreach ($results as $result) {
36                $this->notificationLogRepository->save(
 
35            foreach ($results as $result) {
 
35            foreach ($results as $result) {
36                $this->notificationLogRepository->save(
37                    $this->notificationLogService->createFromNotification(
38                        $notification,
39                        $result
40                    )
41                );
42            }
43        });
33        $this->transactionProvider->transactional(function () use ($notification, $results) {
34            // save logs for the notification
35            foreach ($results as $result) {
 
35            foreach ($results as $result) {
 
35            foreach ($results as $result) {
36                $this->notificationLogRepository->save(
37                    $this->notificationLogService->createFromNotification(
38                        $notification,
39                        $result
40                    )
41                );
42            }
43        });
33        $this->transactionProvider->transactional(function () use ($notification, $results) {
34            // save logs for the notification
35            foreach ($results as $result) {
 
35            foreach ($results as $result) {
36                $this->notificationLogRepository->save(
37                    $this->notificationLogService->createFromNotification(
38                        $notification,
39                        $result
40                    )
41                );
42            }
43        });
{main}
3namespace App\Notification\Application\Handler;
4
5use App\Notification\Domain\Port\Driven\NotificationDispatcher;
6use App\Notification\Domain\Service\NotificationFactory;
7use App\Notification\Domain\Port\Driven\NotificationLogRepository;
8use App\Notification\Domain\Service\NotificationLogService;
9use App\Shared\Domain\Port\Driven\TransactionProvider;
10use MyLegoCollection\SharedContracts\Command\Command;
11
12/**
13 * @author Wilhelm Zwertvaegher
14 */
15readonly class NotificationCommandHandler
16{
17    public function __construct(
18        private NotificationFactory       $notificationFactory,
19        private NotificationDispatcher    $notificationDispatcher,
20        private NotificationLogService    $notificationLogService,
21        private NotificationLogRepository $notificationLogRepository,
22        private TransactionProvider       $transactionProvider
23    ) {
24    }
25    public function __invoke(Command $command): void
26    {
27        // create notification to be sent
28        $notification = $this->notificationFactory->createNotification($command);
29
30        // pass to dispatcher
31        $results = $this->notificationDispatcher->dispatch($notification);
32
33        $this->transactionProvider->transactional(function () use ($notification, $results) {
34            // save logs for the notification
35            foreach ($results as $result) {
36                $this->notificationLogRepository->save(
37                    $this->notificationLogService->createFromNotification(
38                        $notification,
39                        $result
40                    )
41                );
42            }
43        });
44    }