ChangeAvatar::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
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
 * Параметры: string - название изображения без пути и раширения
11
 * Применение в js: Kingdom.Websocket.command('changeAvatar', 'male2')
12
 */
13
class ChangeAvatar extends AbstractGameCommand
14
{
15
16
    /**
17
     * @return CommandResponse
18
     */
19
    public function execute(): CommandResponse
20
    {
21
        if ($this->parameters) {
22
            $this->user->setAvatar($this->parameters);
23
24
            $this->result->setData(['avatar' => $this->user->getAvatar()]);
25
            $this->container->get('doctrine.orm.entity_manager')->flush($this->user);
26
        }
27
28
        return $this->result;
29
    }
30
}
31