Test Setup Failed
Push — develop ( 7bf4d9...2163ff )
by Nikita
06:09
created

ServerResponse::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Gameap\Http\Responses\GdaemonAPI;
4
5
use Gameap\Models\Game;
6
use Gameap\Models\GameMod;
7
use Gameap\Models\Server;
8
use Symfony\Component\Serializer\SerializerInterface;
9
10
class ServerResponse implements \JsonSerializable
11
{
12
    /** @var Server */
13
    private $server;
14
15
    public function __construct(Server $server)
16
    {
17
        $this->server = $server;
18
    }
19
20
    public function jsonSerialize()
21
    {
22
        $gameModResponse = new GameModResponse($this->server->gameMod, $this->server->dedicatedServer->os);
23
        $gameResponse = new GameResponse($this->server->game, $this->server->dedicatedServer->os);
24
25
        return [
26
            'id' => $this->server->id,
27
            'uuid' => $this->server->uuid,
28
            'uuid_short' => $this->server->uuid_short,
29
            'enabled' => $this->server->enabled,
30
            'installed' => $this->server->installed,
31
            'blocked' => $this->server->blocked,
32
            'name' => $this->server->name,
33
            'ds_id' => $this->server->ds_id,
34
            'game_id' => $this->server->game_id,
35
            'game_mod_id' => $this->server->game_mod_id,
36
            'expires' => $this->server->expires,
37
            'server_ip' => $this->server->server_ip,
38
            'server_port' => $this->server->server_port,
39
            'query_port' => $this->server->query_port,
40
            'rcon_port' => $this->server->rcon_port,
41
            'rcon' => $this->server->rcon,
42
            'dir' => $this->server->dir,
43
            'su_user' => $this->server->su_user,
44
            'cpu_limit' => $this->server->cpu_limit,
45
            'ram_limit' => $this->server->ram_limit,
46
            'net_limit' => $this->server->net_limit,
47
            'start_command' => $this->server->start_command,
48
            'stop_command' => $this->server->stop_command,
49
            'force_stop_command' => $this->server->force_stop_command,
50
            'restart_command' => $this->server->restart_command,
51
            'process_active' => $this->server->process_active,
52
            'last_process_check' => $this->server->last_process_check,
53
            'vars' => $this->server->vars,
54
            'created_at' => $this->server->created_at,
55
            'updated_at' => $this->server->updated_at,
56
            'deleted_at' => $this->server->deleted_at,
57
            'settings' => $this->server->settings,
58
            'game' => $gameResponse->jsonSerialize(),
59
            'game_mod' => $gameModResponse->jsonSerialize(),
60
        ];
61
    }
62
}
63