Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
90.91% |
10 / 11 |
|
75.00% |
3 / 4 |
|
66.67% |
2 / 3 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| UserCreatedHandler | |
90.91% |
10 / 11 |
|
75.00% |
3 / 4 |
|
66.67% |
2 / 3 |
|
50.00% |
1 / 2 |
3.33 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| __invoke | |
90.00% |
9 / 10 |
|
66.67% |
2 / 3 |
|
50.00% |
1 / 2 |
|
0.00% |
0 / 1 |
2.50 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Auth\Application\Handler; |
| 4 | |
| 5 | use App\Auth\Domain\Port\Driven\IdentityRepository; |
| 6 | use App\Auth\Domain\Service\IdentityService; |
| 7 | use App\Shared\Domain\Exception\EntityNotFoundException; |
| 8 | use App\Shared\Domain\Model\EntityId; |
| 9 | use App\Shared\Domain\Port\Driven\EventBus; |
| 10 | use App\Shared\Domain\Port\Driven\TransactionProvider; |
| 11 | use MyLegoCollection\SharedContracts\Event\UserCreatedIntegrationEvent; |
| 12 | |
| 13 | readonly class UserCreatedHandler |
| 14 | { |
| 15 | public function __construct( |
| 16 | private IdentityService $identityService, |
| 17 | private IdentityRepository $identityRepository, |
| 18 | private TransactionProvider $transactionProvider, |
| 19 | private EventBus $eventBus |
| 20 | |
| 21 | ) { |
| 22 | } |
| 23 | |
| 24 | public function __invoke(UserCreatedIntegrationEvent $event): void |
| 25 | { |
| 26 | $identityId = EntityId::fromString($event->getEntityId()); |
| 27 | $identity = $this->identityRepository->findById($identityId); |
| 28 | if (null === $identity) { |
| 29 | throw new EntityNotFoundException("Identity with id $identityId could not be found"); |
| 30 | } |
| 31 | |
| 32 | $this->transactionProvider->transactional(function () use ($identity) { |
| 33 | $identity = $this->identityService->complete($identity); |
| 34 | $this->identityRepository->save($identity); |
| 35 | $this->eventBus->dispatchAll($identity); |
| 36 | return $identity; |
| 37 | }); |
| 38 | } |
| 39 | } |
Below are the source code lines that represent each code path as identified by Xdebug. Please note a path is not
necessarily coterminous with a line, a line may contain multiple paths and therefore show up more than once.
Please also be aware that some paths may include implicit rather than explicit branches, e.g. an if statement
always has an else as part of its logical flow even if you didn't write one.
| 15 | public function __construct( |
| 16 | private IdentityService $identityService, |
| 17 | private IdentityRepository $identityRepository, |
| 18 | private TransactionProvider $transactionProvider, |
| 19 | private EventBus $eventBus |
| 20 | |
| 21 | ) { |
| 22 | } |
| 24 | public function __invoke(UserCreatedIntegrationEvent $event): void |
| 25 | { |
| 26 | $identityId = EntityId::fromString($event->getEntityId()); |
| 27 | $identity = $this->identityRepository->findById($identityId); |
| 28 | if (null === $identity) { |
| 29 | throw new EntityNotFoundException("Identity with id $identityId could not be found"); |
| 24 | public function __invoke(UserCreatedIntegrationEvent $event): void |
| 25 | { |
| 26 | $identityId = EntityId::fromString($event->getEntityId()); |
| 27 | $identity = $this->identityRepository->findById($identityId); |
| 28 | if (null === $identity) { |
| 32 | $this->transactionProvider->transactional(function () use ($identity) { |
| 33 | $identity = $this->identityService->complete($identity); |
| 34 | $this->identityRepository->save($identity); |
| 35 | $this->eventBus->dispatchAll($identity); |
| 36 | return $identity; |
| 37 | }); |
| 38 | } |
| 32 | $this->transactionProvider->transactional(function () use ($identity) { |
| 33 | $identity = $this->identityService->complete($identity); |
| 34 | $this->identityRepository->save($identity); |
| 35 | $this->eventBus->dispatchAll($identity); |
| 36 | return $identity; |
| 37 | }); |
| 3 | namespace App\Auth\Application\Handler; |
| 4 | |
| 5 | use App\Auth\Domain\Port\Driven\IdentityRepository; |
| 6 | use App\Auth\Domain\Service\IdentityService; |
| 7 | use App\Shared\Domain\Exception\EntityNotFoundException; |
| 8 | use App\Shared\Domain\Model\EntityId; |
| 9 | use App\Shared\Domain\Port\Driven\EventBus; |
| 10 | use App\Shared\Domain\Port\Driven\TransactionProvider; |
| 11 | use MyLegoCollection\SharedContracts\Event\UserCreatedIntegrationEvent; |
| 12 | |
| 13 | readonly class UserCreatedHandler |
| 14 | { |
| 15 | public function __construct( |
| 16 | private IdentityService $identityService, |
| 17 | private IdentityRepository $identityRepository, |
| 18 | private TransactionProvider $transactionProvider, |
| 19 | private EventBus $eventBus |
| 20 | |
| 21 | ) { |
| 22 | } |
| 23 | |
| 24 | public function __invoke(UserCreatedIntegrationEvent $event): void |
| 25 | { |
| 26 | $identityId = EntityId::fromString($event->getEntityId()); |
| 27 | $identity = $this->identityRepository->findById($identityId); |
| 28 | if (null === $identity) { |
| 29 | throw new EntityNotFoundException("Identity with id $identityId could not be found"); |
| 30 | } |
| 31 | |
| 32 | $this->transactionProvider->transactional(function () use ($identity) { |
| 33 | $identity = $this->identityService->complete($identity); |
| 34 | $this->identityRepository->save($identity); |
| 35 | $this->eventBus->dispatchAll($identity); |
| 36 | return $identity; |
| 37 | }); |
| 38 | } |