Completed
Push — master ( d4bf46...7cdb59 )
by Travis
10s
created

App::getFakeFullgameObject()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 0
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Syntax\SteamApi\Containers;
4
5
use NukaCode\Database\Collection;
6
7
class App extends BaseContainer
8
{
9
    public $id;
10
11
    public $type;
12
13
    public $name;
14
15
    public $controllerSupport;
16
17
    public $description;
18
19
    public $about;
20
21
    public $fullgame;
22
23
    public $header;
24
25
    public $website;
26
27
    public $pcRequirements;
28
29
    public $legal;
30
31
    public $developers;
32
33
    public $publishers;
34
35
    public $price;
36
37
    public $platforms;
38
39
    public $metacritic;
40
41
    public $categories;
42
43 2
    public $genres;
44
45 2
    public $release;
46 2
47 2
    public function __construct($app)
48 2
    {
49 2
        $this->id                = $app->steam_appid;
50 2
        $this->type              = $app->type;
51 2
        $this->name              = $app->name;
52 2
        $this->controllerSupport = $this->checkIssetField($app, 'controller_support', 'None');
53 2
        $this->description       = $app->detailed_description;
54 2
        $this->about             = $app->about_the_game;
55 2
        $this->fullgame          = $this->checkIssetField($app, 'fullgame', $this->getFakeFullgameObject());
56 2
        $this->header            = $app->header_image;
57 2
        $this->website           = $this->checkIsNullField($app, 'website', 'None');
58 2
        $this->pcRequirements    = $app->pc_requirements;
59 2
        $this->legal             = $this->checkIssetField($app, 'legal_notice', 'None');
60 2
        $this->developers        = $this->checkIssetCollection($app, 'developers');
61 2
        $this->publishers        = new Collection($app->publishers);
62 2
        $this->price             = $this->checkIssetField($app, 'price_overview', $this->getFakePriceObject());
63
        $this->platforms         = $app->platforms;
64 2
        $this->metacritic        = $this->checkIssetField($app, 'metacritic', $this->getFakeMetacriticObject());
65
        $this->categories        = $this->checkIssetCollection($app, 'categories');
66 2
        $this->genres            = $this->checkIssetCollection($app, 'genres');
67 2
        $this->release           = $app->release_date;
68 2
    }
69
70 2
    protected function getFakeMetacriticObject()
71
    {
72
        $object        = new \stdClass();
73 2
        $object->url   = null;
74
        $object->score = 'No Score';
75 2
76 2
        return $object;
77
    }
78 2
79
    protected function getFakePriceObject()
80
    {
81 1
        $object        = new \stdClass();
82
        $object->final = 'No price found';
83
84
        return $object;
85
    }
86
87
    protected function getFakeFullgameObject()
88
    {
89
        $object = new \stdClass();
90
        $object->appid = null;
91
        $object->name = 'No parent game found';
92
    }
93
}
94