Conditions | 2 |
Paths | 2 |
Total Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
31 | public function handle(ChangeClientOwner $command): void |
||
32 | { |
||
33 | $client = $this->clientRepository->find($command->getClientId()); |
||
34 | if (!$client) { |
||
35 | throw new \InvalidArgumentException(\sprintf('The client with ID "%s" does not exist.', $command->getClientId()->getValue())); |
||
36 | } |
||
37 | |||
38 | $client->setOwnerId( |
||
39 | $command->getOwnerId() |
||
40 | ); |
||
41 | $this->clientRepository->save($client); |
||
42 | $event = new ClientOwnerChangedEvent( |
||
43 | $command->getClientId(), |
||
44 | $command->getOwnerId() |
||
45 | ); |
||
46 | $this->eventBus->handle($event); |
||
47 | } |
||
48 | } |
||
49 |