Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
CreateUserHandler
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 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
100.00% covered (success)
100.00%
5 / 5
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
1<?php
2
3namespace App\User\Application\Handler;
4
5use App\Shared\Domain\Model\EntityId;
6use App\Shared\Domain\Port\Driven\EventBus;
7use App\Shared\Domain\Port\Driven\TransactionProvider;
8use App\User\Domain\Port\Driven\UserRepository;
9use App\User\Domain\Service\UserService;
10use MyLegoCollection\SharedContracts\Command\CreateUserCommand;
11
12readonly 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}

Branches

Below are the source code lines that represent each code branch as identified by Xdebug. Please note a branch is not necessarily coterminous with a line, a line may contain multiple branches and therefore show up more than once. Please also be aware that some branches may be implicit rather than explicit, e.g. an if statement always has an else as part of its logical flow even if you didn't write one.

CreateUserHandler->__construct
14    public function __construct(
15        private UserService $userService,
16        private UserRepository $userRepository,
17        private TransactionProvider $transactionProvider,
18        private EventBus    $eventBus
19    ) {
20    }
CreateUserHandler->__invoke
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    }
{closure:/home/runner/work/my-lego-collection/my-lego-collection/back/src/User/Application/Handler/CreateUserHandler.php:24-28}
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        });
{main}
3namespace App\User\Application\Handler;
4
5use App\Shared\Domain\Model\EntityId;
6use App\Shared\Domain\Port\Driven\EventBus;
7use App\Shared\Domain\Port\Driven\TransactionProvider;
8use App\User\Domain\Port\Driven\UserRepository;
9use App\User\Domain\Service\UserService;
10use MyLegoCollection\SharedContracts\Command\CreateUserCommand;
11
12readonly 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    }