| Conditions | 3 |
| Paths | 4 |
| Total Lines | 19 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 34 | 3 | public function execute(?string $userId): void |
|
| 35 | { |
||
| 36 | /** @var Interactor|null $io */ |
||
| 37 | 3 | $io = $this->app()?->io(); |
|
| 38 | 3 | $userId = (int) $userId; |
|
| 39 | |||
| 40 | 3 | $user = $this->dic->get(UserRepositoryInterface::class)->find($userId); |
|
| 41 | |||
| 42 | 3 | if ($user === null) { |
|
| 43 | 1 | $io?->error(sprintf('User with id `%d` not found', $userId), true); |
|
| 44 | 1 | return; |
|
| 45 | } |
||
| 46 | |||
| 47 | try { |
||
| 48 | 2 | $this->dic->get(UserDeleterInterface::class)->delete($user); |
|
| 49 | |||
| 50 | 1 | $io?->ok('The user has been deleted', true); |
|
| 51 | 1 | } catch (Throwable) { |
|
| 52 | 1 | $io?->error('Error deleting user (see logs)', true); |
|
| 53 | } |
||
| 56 |