| Conditions | 2 |
| Paths | 2 |
| Total Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 32 | public function handle(CreateClient $command): void |
||
| 33 | { |
||
| 34 | $client = $this->clientRepository->find($command->getClientId()); |
||
| 35 | if ($client) { |
||
| 36 | throw new \InvalidArgumentException(\sprintf('The client with ID "%s" already exist.', $command->getClientId()->getValue())); |
||
| 37 | } |
||
| 38 | |||
| 39 | $client = new Client( |
||
| 40 | $command->getClientId(), |
||
| 41 | $command->getParameter(), |
||
| 42 | false, |
||
| 43 | $command->getOwnerId() |
||
| 44 | ); |
||
| 45 | $this->clientRepository->save($client); |
||
| 46 | $event = new ClientCreatedEvent( |
||
| 47 | $command->getClientId(), |
||
| 48 | $command->getParameter(), |
||
| 49 | $command->getOwnerId() |
||
| 50 | ); |
||
| 51 | $this->eventBus->handle($event); |
||
| 52 | } |
||
| 53 | } |
||
| 54 |