| Conditions | 3 |
| Paths | 3 |
| Total Lines | 25 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 20 | public function execute() { |
||
| 21 | $parameters = explode(':', $this->parameters); |
||
| 22 | $itemId = $parameters[0]; |
||
| 23 | $slot = $parameters[1]; |
||
| 24 | |||
| 25 | $inventoryItemRepository = $this->container->get('kingdom.inventory_item_repository'); |
||
| 26 | $inventoryItem = $inventoryItemRepository->findOneByUserAndItemId($this->user, $itemId); |
||
| 27 | |||
| 28 | if (!$inventoryItem->getItem()->fitsTo($slot)) { |
||
| 29 | throw new WrongSlot($slot); |
||
| 30 | } |
||
| 31 | |||
| 32 | $wornItem = $inventoryItemRepository->findOneByUserAndSlot($this->user, $slot); |
||
| 33 | |||
| 34 | if ($wornItem) { |
||
| 35 | $wornItem->removeSlot(); |
||
| 36 | $inventoryItemRepository->flush($wornItem); |
||
| 37 | } |
||
| 38 | |||
| 39 | $inventoryItem->setSlot($slot); |
||
| 40 | |||
| 41 | $inventoryItemRepository->flush($inventoryItem); |
||
| 42 | |||
| 43 | return $this->result; |
||
| 44 | } |
||
| 45 | } |
||
| 46 |