| Conditions | 3 |
| Paths | 6 |
| Total Lines | 14 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 3.0123 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 42 | 2 | public function __invoke(DeleteItemCommand $command) |
|
| 43 | { |
||
| 44 | try { |
||
| 45 | 2 | $item = $this->repository->getItem($command->getId()); |
|
| 46 | |||
| 47 | 1 | if ($item->getLoaned()) { |
|
| 48 | throw new ItemNotDeletedException('Item has loan record'); |
||
| 49 | } |
||
| 50 | |||
| 51 | 1 | $this->repository->delete($item); |
|
| 52 | 1 | $this->eventBus->dispatch(new ItemDeletedEvent($command->getId()->toString())); |
|
| 53 | 1 | } catch (\Exception $e) { |
|
| 54 | 1 | $this->logger->error($e->getMessage()); |
|
| 55 | 1 | throw new ItemNotDeletedException('Item was not deleted: '.$e->getMessage()); |
|
| 56 | } |
||
| 60 |