| Conditions | 3 |
| Paths | 3 |
| Total Lines | 33 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | public function execute(): CommandResponse |
||
| 21 | { |
||
| 22 | $userToLookAt = $this->container->get('kingdom.human_repository')->findByName($this->parameters); |
||
| 23 | |||
| 24 | if (!$userToLookAt) { |
||
| 25 | throw new UserNotFound; |
||
| 26 | } |
||
| 27 | |||
| 28 | $itemData = []; |
||
| 29 | foreach ($this->container->get('kingdom.inventory_item_repository')->findByUser( |
||
| 30 | $userToLookAt |
||
| 31 | ) as $inventoryItem) { |
||
| 32 | $item = $inventoryItem->getItem(); |
||
| 33 | |||
| 34 | $itemData[] = [ |
||
| 35 | 'name' => $item->getName(), |
||
| 36 | 'description' => $item->getDescription(), |
||
| 37 | 'slots' => $item->getSlots(), |
||
| 38 | 'pic' => $item->getPicture(), |
||
| 39 | 'slot' => $inventoryItem->getSlot(), |
||
| 40 | ]; |
||
| 41 | } |
||
| 42 | |||
| 43 | $this->result->setData( |
||
| 44 | [ |
||
| 45 | 'name' => $userToLookAt->getName(), |
||
| 46 | 'items' => $itemData, |
||
| 47 | 'avatar' => $userToLookAt->getAvatar(), |
||
| 48 | ] |
||
| 49 | ); |
||
| 50 | |||
| 51 | return $this->result; |
||
| 52 | } |
||
| 53 | } |
||
| 54 |