Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| CreateUserHandler | |
100.00% |
6 / 6 |
|
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% |
5 / 5 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\User\Application\Handler; |
| 4 | |
| 5 | use App\Shared\Domain\Model\EntityId; |
| 6 | use App\Shared\Domain\Port\Driven\EventBus; |
| 7 | use App\Shared\Domain\Port\Driven\TransactionProvider; |
| 8 | use App\User\Domain\Port\Driven\UserRepository; |
| 9 | use App\User\Domain\Service\UserService; |
| 10 | use MyLegoCollection\SharedContracts\Command\CreateUserCommand; |
| 11 | |
| 12 | readonly class CreateUserHandler |
| 13 | { |
| 14 | public function __construct( |
| 15 | private UserService $userService, |
| 16 | private UserRepository $userRepository, |
| 17 | private TransactionProvider $transactionProvider, |
| 18 | private EventBus $eventBus |
| 19 | ) { |
| 20 | } |
| 21 | |
| 22 | public function __invoke(CreateUserCommand $command): void |
| 23 | { |
| 24 | $this->transactionProvider->transactional(function () use ($command) { |
| 25 | $user = $this->userService->createUser(EntityId::fromString($command->getIdentityId())); |
| 26 | $this->userRepository->save($user); |
| 27 | $this->eventBus->dispatchAll($user); |
| 28 | }); |
| 29 | } |
| 30 | } |