1 | <?php namespace Syntax\SteamApi\Containers; |
||
3 | class Game extends BaseContainer { |
||
4 | public $appId; |
||
5 | |||
6 | public $name; |
||
7 | |||
8 | public $playtimeTwoWeeks; |
||
9 | |||
10 | public $playtimeForever; |
||
11 | |||
12 | public $playtimeForeverReadable; |
||
13 | |||
14 | public $icon; |
||
15 | |||
16 | public $logo; |
||
17 | |||
18 | public $header; |
||
19 | |||
20 | public $hasCommunityVisibleStats; |
||
21 | |||
22 | public function __construct($app) |
||
23 | { |
||
24 | $this->appId = $app->appid; |
||
25 | $this->name = $this->checkIssetField($app, 'name'); |
||
26 | $this->playtimeTwoWeeks = isset($app->playtime_2weeks) ? $this->convertFromMinutes($app->playtime_2weeks) : '0 minutes'; |
||
27 | $this->playtimeForever = $this->checkIssetField($app, 'playtime_forever', 0); |
||
28 | $this->playtimeForeverReadable = $this->convertFromMinutes($this->playtimeForever); |
||
29 | $this->icon = $this->checkIssetImage($app, 'img_icon_url'); |
||
30 | $this->logo = $this->checkIssetImage($app, 'img_logo_url'); |
||
31 | $this->header = 'http://cdn.steampowered.com/v/gfx/apps/'. $this->appId .'/header.jpg'; |
||
32 | $this->hasCommunityVisibleStats = $this->checkIssetField($app, 'has_community_visible_stats', 0); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * @param $app |
||
37 | * @param string $field |
||
38 | * @param string $value |
||
39 | * |
||
40 | * @return null|string |
||
41 | */ |
||
42 | protected function checkIssetImage($app, $field, $value = null) |
||
46 | |||
47 | protected function getImageForGame($appId, $hash) |
||
55 | |||
56 | protected function convertFromMinutes($minutes) |
||
85 | |||
86 | } |