Skip to content

Commit ee9b02a

Browse files
committed
Minor fixes from scrute. Allowing for an array of ids to be passed to the initial calls to a service.
1 parent 88e4a0e commit ee9b02a

File tree

3 files changed

+29
-19
lines changed

3 files changed

+29
-19
lines changed

src/Syntax/SteamApi/Client.php

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ public function __construct()
5050

5151
// Set up the Ids
5252
$this->setUpFormatted();
53-
54-
return $this;
5553
}
5654

5755
public function get()
@@ -179,10 +177,7 @@ public function __call($name, $arguments)
179177
if (! empty($arguments) && count($arguments) == 1) {
180178
$this->steamId = $arguments[0];
181179

182-
if (strpos(':', $this->steamId) !== false) {
183-
// Convert the id to all types and grab the 64 bit version
184-
$this->steamId = $this->convertToAll($this->steamId)[2];
185-
}
180+
$this->convertSteamIdTo64();
186181
}
187182

188183
// Inside the root steam directory
@@ -206,20 +201,22 @@ public function __call($name, $arguments)
206201
}
207202

208203
/**
209-
* @param Collection $objects
210-
*/
211-
protected function sortObjects($objects)
204+
* @param Collection $objects
205+
*
206+
* @return $this
207+
*/
208+
protected function sortObjects($objects)
212209
{
213210
return $objects->sortBy(function ($object) {
214211
return $object->name;
215212
});
216213
}
217214

218215
/**
219-
* @param string $method
220-
* @param string $version
221-
*/
222-
protected function setApiDetails($method, $version)
216+
* @param string $method
217+
* @param string $version
218+
*/
219+
protected function setApiDetails($method, $version)
223220
{
224221
$this->method = $method;
225222
$this->version = $version;
@@ -252,4 +249,19 @@ protected function getApiKey()
252249

253250
return $apiKey;
254251
}
252+
253+
private function convertSteamIdTo64()
254+
{
255+
if (is_array($this->steamId)) {
256+
$this->steamId = array_walk($this->steamId, function (&$id, $key) {
257+
if (strpos($id, ':') !== false) {
258+
// Convert the id to all types and grab the 64 bit version
259+
return $this->convertToAll($this->steamId)[2];
260+
}
261+
});
262+
} elseif (strpos(':', $this->steamId) !== false) {
263+
// Convert the id to all types and grab the 64 bit version
264+
$this->steamId = $this->convertToAll($this->steamId)[2];
265+
}
266+
}
255267
}

src/Syntax/SteamApi/Command/SteamAppGrabber.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ class SteamAppGrabber extends Command {
2222

2323
/**
2424
* Create a new command instance.
25-
*
26-
* @return void
2725
*/
2826
public function __construct()
2927
{

src/Syntax/SteamApi/Steam/User.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ public function GetPlayerSummaries($steamId = null)
2929
$this->version = 'v0002';
3030

3131
if ($steamId == null) {
32-
$steamId = (array) $this->steamId;
32+
$steamId = $this->steamId;
3333
}
3434

35-
$steamId = implode(',', $steamId);
35+
$steamId = implode(',', (array) $steamId);
3636

3737
$chunks = array_chunk(explode(',', $steamId), 100);
3838

@@ -78,12 +78,12 @@ public function GetPlayerBans($steamId = null)
7878
$this->version = 'v1';
7979

8080
if ($steamId == null) {
81-
$steamId = (array) $this->steamId;
81+
$steamId = $this->steamId;
8282
}
8383

8484
// Set up the arguments
8585
$arguments = [
86-
'steamids' => implode(',', $steamId)
86+
'steamids' => implode(',', (array) $steamId)
8787
];
8888

8989
// Get the client

0 commit comments

Comments
 (0)