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}