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 |
| RegistrationHandler | |
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\Auth\Application\Handler; |
| 4 | |
| 5 | use App\Auth\Application\Command\RegistrationCommand; |
| 6 | use App\Auth\Domain\Port\Driven\IdentityRepository; |
| 7 | use App\Auth\Domain\Service\IdentityService; |
| 8 | use App\Shared\Domain\Port\Driven\EventBus; |
| 9 | use App\Shared\Domain\Port\Driven\TransactionProvider; |
| 10 | |
| 11 | readonly class RegistrationHandler |
| 12 | { |
| 13 | public function __construct( |
| 14 | private IdentityService $identityService, |
| 15 | private IdentityRepository $identityRepository, |
| 16 | private TransactionProvider $transactionProvider, |
| 17 | private EventBus $eventBus |
| 18 | ) { |
| 19 | } |
| 20 | |
| 21 | public function __invoke(RegistrationCommand $command): void |
| 22 | { |
| 23 | $this->transactionProvider->transactional(function () use ($command) { |
| 24 | $identity = $this->identityService->createIdentity($command->email, $command->username, $command->password); |
| 25 | $this->identityRepository->save($identity); |
| 26 | $this->eventBus->dispatchAll($identity); |
| 27 | }); |
| 28 | } |
| 29 | } |