ChangeAvatar   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 11 2
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