| Conditions | 3 |
| Paths | 3 |
| Total Lines | 18 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 31 | public function __invoke(CreateUser $command): void |
||
| 32 | { |
||
| 33 | if ($this->repository->existWithUsername($command->username()->getValue())) { |
||
| 34 | throw new \DomainException("User with username: {$command->username()->getValue()} already exist"); |
||
| 35 | } |
||
| 36 | if ($this->repository->existWithEmail($command->email()->getValue())) { |
||
| 37 | throw new \DomainException("User with email: {$command->email()->getValue()} already exist"); |
||
| 38 | } |
||
| 39 | |||
| 40 | $user = User::create( |
||
| 41 | UserUuid::generate(), |
||
| 42 | $command->username(), |
||
| 43 | $command->email(), |
||
| 44 | $command->password(), |
||
| 45 | $command->roles() |
||
| 46 | ); |
||
| 47 | |||
| 48 | $this->repository->add($user); |
||
| 49 | } |
||
| 51 |