Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
7 / 7 |
|
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| CreateReport | |
100.00% |
7 / 7 |
|
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| __invoke | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Application\UseCase; |
| 4 | |
| 5 | use App\Dto\Command\CreateReportCommand; |
| 6 | use App\Entity\Report; |
| 7 | use App\Message\CommandBus; |
| 8 | use App\Message\SendNotificationCommand; |
| 9 | use App\Service\Data\NotificationServiceInterface; |
| 10 | use App\Service\Data\ReportServiceInterface; |
| 11 | use App\Service\Notification\Factory\NotificationPropsFactoryInterface; |
| 12 | use Doctrine\ORM\EntityManagerInterface; |
| 13 | |
| 14 | /** |
| 15 | * @author Wilhelm Zwertvaegher |
| 16 | */ |
| 17 | readonly 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 | } |