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

GameResponse::jsonSerialize()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 26
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 21
c 1
b 0
f 1
dl 0
loc 26
rs 9.584
cc 3
nc 3
nop 0
1
<?php
2
3
namespace Gameap\Http\Responses\GdaemonAPI;
4
5
use Gameap\Models\Game;
6
7
class GameResponse implements \JsonSerializable
8
{
9
    /** @var Game */
10
    private $game;
11
12
    private $os;
13
14
    public function __construct(Game $game, string $os = 'linux')
15
    {
16
        $this->game = $game;
17
        $this->os = $os;
18
    }
19
20
    public function jsonSerialize()
21
    {
22
        $remoteRepository = '';
23
        $localRepository = '';
24
        $steamAppId = '';
25
26
        if ($this->os === 'linux') {
27
            $remoteRepository = $this->game->remote_repository_linux;
28
            $localRepository = $this->game->local_repository_linux;
29
            $steamAppId = $this->game->steam_app_id_linux;
30
        } elseif ($this->os === 'windows') {
31
            $remoteRepository = $this->game->remote_repository_windows;
32
            $localRepository = $this->game->local_repository_windows;
33
            $steamAppId = $this->game->steam_app_id_windows;
34
        }
35
36
        return [
37
            'code' => $this->game->code,
38
            'start_code' => $this->game->start_code,
39
            'name' => $this->game->name,
40
            'engine' => $this->game->engine,
41
            'engine_version' => $this->game->engine_version,
42
            'remote_repository' => $remoteRepository,
43
            'local_repository' => $localRepository,
44
            'steam_app_id' => $steamAppId,
45
            'steam_app_set_config' => $this->game->steam_app_set_config,
46
        ];
47
    }
48
}
49