1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Syntax\SteamApi\Steam; |
4
|
|
|
|
5
|
|
|
use Syntax\SteamApi\Client; |
6
|
|
|
use NukaCode\Database\Collection; |
7
|
|
|
use Syntax\SteamApi\Containers\Item as ItemContainer; |
8
|
|
|
|
9
|
|
|
class Item extends Client |
10
|
|
|
{ |
11
|
|
|
public function __construct() |
12
|
|
|
{ |
13
|
|
|
parent::__construct(); |
14
|
|
|
$this->url = 'http://store.steampowered.com/'; |
15
|
|
|
$this->isService = true; |
16
|
|
|
$this->interface = 'api'; |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
public function GetPlayerItems($appId, $steamId) |
20
|
|
|
{ |
21
|
|
|
// Set up the api details |
22
|
|
|
$this->url = 'http://api.steampowered.com/'; |
23
|
|
|
$this->interface = 'IEconItems_' . $appId; |
24
|
|
|
$this->method = __FUNCTION__; |
25
|
|
|
$this->version = 'v0001'; |
26
|
|
|
|
27
|
|
|
$arguments = ['steamId' => $steamId]; |
28
|
|
|
|
29
|
|
|
// Get the client |
30
|
|
|
$client = $this->setUpClient($arguments); |
31
|
|
|
dd($client); |
32
|
|
|
|
33
|
|
|
// Clean up the items |
34
|
|
|
$items = $this->convertToObjects($client->result->items, $client->result->qualities); |
35
|
|
|
|
36
|
|
|
return $items; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
protected function convertToObjects($items, $qualities) |
40
|
|
|
{ |
41
|
|
|
$convertedItems = $this->convertGames($items, $qualities); |
|
|
|
|
42
|
|
|
|
43
|
|
|
$items = $this->sortObjects($convertedItems); |
44
|
|
|
|
45
|
|
|
return $items; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param array $items |
50
|
|
|
* |
51
|
|
|
* @return Collection |
52
|
|
|
*/ |
53
|
|
|
protected function convertItems($items, $qualities) |
54
|
|
|
{ |
55
|
|
|
$convertedItems = new Collection(); |
56
|
|
|
|
57
|
|
|
foreach ($items as $item) { |
58
|
|
|
if (isset($item->data)) { |
59
|
|
|
$convertedItems->add(new ItemContainer($item->data, $qualities)); |
|
|
|
|
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
return $convertedItems; |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: