Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
90.91% covered (success)
90.91%
10 / 11
75.00% covered (warning)
75.00%
3 / 4
66.67% covered (warning)
66.67%
2 / 3
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
UserCreatedHandler
90.91% covered (success)
90.91%
10 / 11
75.00% covered (warning)
75.00%
3 / 4
66.67% covered (warning)
66.67%
2 / 3
50.00% covered (danger)
50.00%
1 / 2
3.33
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 __invoke
90.00% covered (success)
90.00%
9 / 10
66.67% covered (warning)
66.67%
2 / 3
50.00% covered (danger)
50.00%
1 / 2
0.00% covered (danger)
0.00%
0 / 1
2.50
1<?php
2
3namespace App\Auth\Application\Handler;
4
5use App\Auth\Domain\Port\Driven\IdentityRepository;
6use App\Auth\Domain\Service\IdentityService;
7use App\Shared\Domain\Exception\EntityNotFoundException;
8use App\Shared\Domain\Model\EntityId;
9use App\Shared\Domain\Port\Driven\EventBus;
10use App\Shared\Domain\Port\Driven\TransactionProvider;
11use MyLegoCollection\SharedContracts\Event\UserCreatedIntegrationEvent;
12
13readonly 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}

Paths

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.

UserCreatedHandler->__construct
15    public function __construct(
16        private IdentityService  $identityService,
17        private IdentityRepository  $identityRepository,
18        private TransactionProvider $transactionProvider,
19        private EventBus $eventBus
20
21    ) {
22    }
UserCreatedHandler->__invoke
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    }
{closure:/home/runner/work/my-lego-collection/my-lego-collection/back/src/Auth/Application/Handler/UserCreatedHandler.php:32-37}
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        });
{main}
3namespace App\Auth\Application\Handler;
4
5use App\Auth\Domain\Port\Driven\IdentityRepository;
6use App\Auth\Domain\Service\IdentityService;
7use App\Shared\Domain\Exception\EntityNotFoundException;
8use App\Shared\Domain\Model\EntityId;
9use App\Shared\Domain\Port\Driven\EventBus;
10use App\Shared\Domain\Port\Driven\TransactionProvider;
11use MyLegoCollection\SharedContracts\Event\UserCreatedIntegrationEvent;
12
13readonly 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    }