Code Duplication    Length = 22-22 lines in 2 locations

Notifier/src/Kreta/Notifier/Domain/Event/Inbox/UserSignedUpSubscriber.php 1 location

@@ 23-44 (lines=22) @@
20
use Kreta\SharedKernel\Domain\Model\AsyncDomainEvent;
21
use Kreta\SharedKernel\Domain\Model\AsyncDomainEventValueDoesNotExistException;
22
23
class UserSignedUpSubscriber implements AsyncEventSubscriber
24
{
25
    private $commandBus;
26
27
    public function __construct(CommandBus $commandBus)
28
    {
29
        $this->commandBus = $commandBus;
30
    }
31
32
    public function handle(AsyncDomainEvent $event) : void
33
    {
34
        if (!isset($event->values()['userId'])) {
35
            throw new AsyncDomainEventValueDoesNotExistException('userId');
36
        }
37
38
        $this->commandBus->handle(
39
            new SignUpUserCommand(
40
                $event->values()['userId']
41
            )
42
        );
43
    }
44
}
45

TaskManager/src/Kreta/TaskManager/Domain/Event/User/UserRegisteredSubscriber.php 1 location

@@ 23-44 (lines=22) @@
20
use Kreta\SharedKernel\Domain\Model\AsyncDomainEventValueDoesNotExistException;
21
use Kreta\TaskManager\Application\Command\User\AddUserCommand;
22
23
class UserRegisteredSubscriber implements AsyncEventSubscriber
24
{
25
    private $commandBus;
26
27
    public function __construct(CommandBus $commandBus)
28
    {
29
        $this->commandBus = $commandBus;
30
    }
31
32
    public function handle(AsyncDomainEvent $event) : void
33
    {
34
        if (!isset($event->values()['userId'])) {
35
            throw new AsyncDomainEventValueDoesNotExistException('userId');
36
        }
37
38
        $this->commandBus->handle(
39
            new AddUserCommand(
40
                $event->values()['userId']
41
            )
42
        );
43
    }
44
}
45