GetMoney::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
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
 * Применение в js: Kingdom.Websocket.command('getMoney')
11
 */
12
class GetMoney extends AbstractGameCommand
13
{
14
15
    /** {@inheritDoc} */
16
    public function execute(): CommandResponse
17
    {
18
        $moneyRepository = $this->container->get('kingdom.money_repository');
19
        $money = $moneyRepository->findOneByUser($this->user);
20
21
        if ($money) {
22
            $this->result->setData(
23
                [
24
                    'gold'   => $money->getGold(),
25
                    'silver' => $money->getSilver(),
26
                ]
27
            );
28
        }
29
30
31
        return $this->result;
32
    }
33
}
34