Test Setup Failed
Branch develop (2163ff)
by Nikita
05:54
created

GameResponse   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
eloc 26
c 1
b 0
f 1
dl 0
loc 39
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A jsonSerialize() 0 26 3
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