Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
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
CreateReport
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
2
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%
6 / 6
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\Application\UseCase;
4
5use App\Dto\Command\CreateReportCommand;
6use App\Entity\Report;
7use App\Message\CommandBus;
8use App\Message\SendNotificationCommand;
9use App\Service\Data\NotificationServiceInterface;
10use App\Service\Data\ReportServiceInterface;
11use App\Service\Notification\Factory\NotificationPropsFactoryInterface;
12use Doctrine\ORM\EntityManagerInterface;
13
14/**
15 * @author Wilhelm Zwertvaegher
16 */
17readonly class CreateReport implements CreateReportInterface
18{
19    public function __construct(
20        private ReportServiceInterface $reportService,
21        private NotificationServiceInterface $notificationService,
22        private EntityManagerInterface $entityManager,
23        private NotificationPropsFactoryInterface $notificationFactory,
24        private CommandBus $commandBus,
25    ) {
26    }
27
28    public function __invoke(CreateReportCommand $command): Report
29    {
30        $report = $this->reportService->create($command);
31        $notificationProps = $this->notificationFactory->create($report);
32        $notification = $this->notificationService->create($notificationProps);
33        $this->entityManager->flush();
34        $this->commandBus->dispatch(new SendNotificationCommand($notification->getId()));
35
36        return $report;
37    }
38}

Branches

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

CreateReport->__construct
19    public function __construct(
20        private ReportServiceInterface $reportService,
21        private NotificationServiceInterface $notificationService,
22        private EntityManagerInterface $entityManager,
23        private NotificationPropsFactoryInterface $notificationFactory,
24        private CommandBus $commandBus,
25    ) {
26    }
CreateReport->__invoke
28    public function __invoke(CreateReportCommand $command): Report
29    {
30        $report = $this->reportService->create($command);
31        $notificationProps = $this->notificationFactory->create($report);
32        $notification = $this->notificationService->create($notificationProps);
33        $this->entityManager->flush();
34        $this->commandBus->dispatch(new SendNotificationCommand($notification->getId()));
35
36        return $report;
37    }
{main}
3namespace App\Application\UseCase;
4
5use App\Dto\Command\CreateReportCommand;
6use App\Entity\Report;
7use App\Message\CommandBus;
8use App\Message\SendNotificationCommand;
9use App\Service\Data\NotificationServiceInterface;
10use App\Service\Data\ReportServiceInterface;
11use App\Service\Notification\Factory\NotificationPropsFactoryInterface;
12use Doctrine\ORM\EntityManagerInterface;
13
14/**
15 * @author Wilhelm Zwertvaegher
16 */
17readonly class CreateReport implements CreateReportInterface
18{
19    public function __construct(
20        private ReportServiceInterface $reportService,
21        private NotificationServiceInterface $notificationService,
22        private EntityManagerInterface $entityManager,
23        private NotificationPropsFactoryInterface $notificationFactory,
24        private CommandBus $commandBus,
25    ) {
26    }
27
28    public function __invoke(CreateReportCommand $command): Report
29    {
30        $report = $this->reportService->create($command);
31        $notificationProps = $this->notificationFactory->create($report);
32        $notification = $this->notificationService->create($notificationProps);
33        $this->entityManager->flush();
34        $this->commandBus->dispatch(new SendNotificationCommand($notification->getId()));
35
36        return $report;
37    }