|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Syntax\SteamApi\Containers; |
|
4
|
|
|
|
|
5
|
|
|
class Game extends BaseContainer |
|
6
|
|
|
{ |
|
7
|
|
|
public $appId; |
|
8
|
|
|
|
|
9
|
|
|
public $name; |
|
10
|
|
|
|
|
11
|
|
|
public $playtimeTwoWeeks; |
|
12
|
|
|
|
|
13
|
|
|
public $playtimeTwoWeeksReadable; |
|
14
|
|
|
|
|
15
|
|
|
public $playtimeForever; |
|
16
|
|
|
|
|
17
|
|
|
public $playtimeForeverReadable; |
|
18
|
|
|
|
|
19
|
|
|
public $icon; |
|
20
|
|
|
|
|
21
|
|
|
public $logo; |
|
22
|
|
|
|
|
23
|
|
|
public $header; |
|
24
|
|
|
|
|
25
|
|
|
public $hasCommunityVisibleStats; |
|
26
|
|
|
|
|
27
|
5 |
|
public function __construct($app) |
|
28
|
|
|
{ |
|
29
|
5 |
|
$this->appId = $app->appid; |
|
30
|
5 |
|
$this->name = $this->checkIssetField($app, 'name'); |
|
31
|
5 |
|
$this->playtimeTwoWeeks = $this->checkIssetField($app, 'playtime_2weeks', 0); |
|
32
|
5 |
|
$this->playtimeTwoWeeksReadable = $this->convertFromMinutes($this->playtimeTwoWeeks); |
|
33
|
5 |
|
$this->playtimeForever = $this->checkIssetField($app, 'playtime_forever', 0); |
|
34
|
5 |
|
$this->playtimeForeverReadable = $this->convertFromMinutes($this->playtimeForever); |
|
35
|
5 |
|
$this->icon = $this->checkIssetImage($app, 'img_icon_url'); |
|
36
|
5 |
|
$this->logo = $this->checkIssetImage($app, 'img_logo_url'); |
|
37
|
5 |
|
$this->header = 'http://cdn.akamai.steamstatic.com/steam/apps/' . $this->appId . '/header.jpg'; |
|
38
|
5 |
|
$this->hasCommunityVisibleStats = $this->checkIssetField($app, 'has_community_visible_stats', 0); |
|
39
|
5 |
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param $app |
|
43
|
|
|
* @param string $field |
|
44
|
|
|
* @param string $value |
|
45
|
|
|
* |
|
46
|
|
|
* @return null|string |
|
47
|
|
|
*/ |
|
48
|
5 |
|
protected function checkIssetImage($app, $field, $value = null) |
|
49
|
|
|
{ |
|
50
|
5 |
|
return isset($app->$field) ? $this->getImageForGame($app->appid, $app->$field) : $value; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
4 |
|
protected function getImageForGame($appId, $hash) |
|
54
|
|
|
{ |
|
55
|
4 |
|
if ($hash != null) { |
|
56
|
4 |
|
return 'http://media.steampowered.com/steamcommunity/public/images/apps/' . $appId . '/' . $hash . '.jpg'; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
1 |
|
return null; |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|