1 | <?php namespace Syntax\SteamApi\Steam\User; |
||
6 | class Stats extends Client |
||
7 | { |
||
8 | |||
9 | 6 | public function __construct($steamId) |
|
15 | |||
16 | /** |
||
17 | * @deprecated |
||
18 | * |
||
19 | * @param $appId |
||
20 | * |
||
21 | * @return array |
||
22 | */ |
||
23 | 1 | public function GetPlayerAchievementsAPI($appId) |
|
52 | |||
53 | 2 | public function GetPlayerAchievements($appId) |
|
54 | { |
||
55 | // Set up the api details |
||
56 | 2 | $this->interface = null; |
|
57 | 2 | $this->method = 'achievements'; |
|
58 | |||
59 | 2 | if (is_numeric($this->steamId)) { |
|
60 | 2 | $this->url = 'http://steamcommunity.com/profiles/'; |
|
61 | 2 | } else { |
|
62 | $this->url = 'http://steamcommunity.com/id/'; |
||
63 | } |
||
64 | |||
65 | 2 | $this->url = $this->url . $this->steamId . '/stats/' . $appId; |
|
66 | |||
67 | // Set up the arguments |
||
68 | $arguments = [ |
||
69 | 'xml' => 1 |
||
70 | 2 | ]; |
|
71 | |||
72 | try { |
||
73 | // Get the client |
||
74 | 2 | $client = $this->setUpXml($arguments); |
|
75 | |||
76 | // Clean up the games |
||
77 | 1 | $achievements = $this->convertToObjects($client->achievements->achievement); |
|
78 | |||
79 | 1 | return $achievements; |
|
80 | 1 | } catch (\Exception $e) { |
|
81 | // In rare cases, games can force the use of a simplified name instead of an app ID |
||
82 | // In these cases, try again with the name. |
||
83 | 1 | if (is_int($appId)) { |
|
84 | 1 | $app = $this->app()->appDetails($appId); |
|
85 | $appName = str_replace(' ', '', $app->first()->name); |
||
86 | |||
87 | return $this->GetPlayerAchievements($appName); |
||
88 | } |
||
89 | |||
90 | // If the name and ID fail, return null. |
||
91 | return null; |
||
92 | } |
||
93 | } |
||
94 | |||
95 | 1 | public function GetGlobalAchievementPercentagesForApp($gameId) |
|
96 | { |
||
97 | // Set up the api details |
||
98 | 1 | $this->method = __FUNCTION__; |
|
99 | 1 | $this->version = 'v0002'; |
|
100 | |||
101 | // Set up the arguments |
||
102 | $arguments = [ |
||
103 | 1 | 'gameid' => $gameId, |
|
104 | 1 | 'l' => 'english', |
|
105 | 1 | ]; |
|
106 | |||
107 | // Get the client |
||
108 | 1 | $client = $this->setUpClient($arguments)->achievementpercentages; |
|
109 | |||
110 | return $client->achievements; |
||
111 | } |
||
112 | |||
113 | /** |
||
114 | * @param $appId int Steam 64 id |
||
115 | * @param $all bool Return all stats when true and only achievements when false |
||
116 | * |
||
117 | * @return mixed |
||
118 | */ |
||
119 | 2 | public function GetUserStatsForGame($appId, $all = false) |
|
142 | |||
143 | /** |
||
144 | * @param $appId |
||
145 | * |
||
146 | * @link https://wiki.teamfortress.com/wiki/WebAPI/GetSchemaForGame |
||
147 | * |
||
148 | * @return mixed |
||
149 | */ |
||
150 | 1 | public function GetSchemaForGame($appId) |
|
167 | |||
168 | 1 | protected function convertToObjects($achievements) |
|
178 | } |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.