Remove::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
namespace Rottenwood\KingdomBundle\Command\Game;
4
5
use Rottenwood\KingdomBundle\Command\Infrastructure\AbstractGameCommand;
6
use Rottenwood\KingdomBundle\Command\Infrastructure\CommandResponse;
7
8
/**
9
 * Снять предмет
10
 * Список слотов доступен в статическом методе Item::getAllSlotNames()
11
 * Применение в js: Kingdom.Websocket.command('remove', 'названиеСлота')
12
 */
13
class Remove extends AbstractGameCommand
14
{
15
16
    /** {@inheritDoc} */
17
    public function execute(): CommandResponse
18
    {
19
        $inventoryItemRepository = $this->container->get('kingdom.inventory_item_repository');
20
        $item = $inventoryItemRepository->findOneByUserAndSlot($this->user, $this->parameters);
21
        $item->removeSlot();
22
23
        $inventoryItemRepository->flush();
24
25
        $this->result->setData(['slot' => $this->parameters]);
26
27
        return $this->result;
28
    }
29
}
30