Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
13 / 13 |
|
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| IdentityCreatedOrchestrator | |
100.00% |
13 / 13 |
|
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% |
12 / 12 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Auth\Application\Orchestrator; |
| 4 | |
| 5 | use App\Auth\Domain\Event\IdentityCreatedEvent; |
| 6 | use App\Shared\Infrastructure\Messenger\CommandBus; |
| 7 | use App\Shared\Infrastructure\Messenger\IntegrationEventBus; |
| 8 | use MyLegoCollection\SharedContracts\Command\CreateUserCommand; |
| 9 | use MyLegoCollection\SharedContracts\Event\IdentityCreatedIntegrationEvent; |
| 10 | |
| 11 | /** |
| 12 | * @author Wilhelm Zwertvaegher |
| 13 | */ |
| 14 | readonly class IdentityCreatedOrchestrator |
| 15 | { |
| 16 | public function __construct( |
| 17 | private CommandBus $commandBus, |
| 18 | private IntegrationEventBus $integrationBus, |
| 19 | ) { |
| 20 | } |
| 21 | |
| 22 | public function __invoke(IdentityCreatedEvent $event): void |
| 23 | { |
| 24 | // identity creation MUST trigger user creation |
| 25 | $this->commandBus->dispatch( |
| 26 | new CreateUserCommand( |
| 27 | $event->getIdentity()->getId(), |
| 28 | $event->metadata() |
| 29 | ), |
| 30 | ); |
| 31 | |
| 32 | // an integration event should be dispatched for possible handlers |
| 33 | $this->integrationBus->dispatch( |
| 34 | new IdentityCreatedIntegrationEvent( |
| 35 | $event->getIdentity()->getId(), |
| 36 | $event->metadata() |
| 37 | ) |
| 38 | ); |
| 39 | } |
| 40 | |
| 41 | } |