ShowPlayersInRoom   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 19 1
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
use Rottenwood\KingdomBundle\Entity\Infrastructure\User;
8
9
/**
10
 * Отображение игроков в текущей комнате
11
 * Применение в js: Kingdom.Websocket.command('showPlayersInRoom')
12
 */
13
class ShowPlayersInRoom extends AbstractGameCommand
14
{
15
16
    /** {@inheritDoc} */
17
    public function execute(): CommandResponse
18
    {
19
        $playersInRoom = array_map(
20
            function (User $user) {
21
                return [
22
                    'name'   => $user->getName(),
23
                    'stance' => 'стоит тут.',
24
                ];
25
            },
26
            $this->container->get('kingdom.user_service')->getOnlineHumansInRoom(
27
                $this->user->getRoom(),
28
                $this->user->getId()
29
            )
30
        );
31
32
        $this->result->setData($playersInRoom);
33
34
        return $this->result;
35
    }
36
}
37