Skip to content

Commit 98af434

Browse files
committed
[Laravel 10] Cleanup
1 parent ef5b7e0 commit 98af434

File tree

6 files changed

+38
-118
lines changed

6 files changed

+38
-118
lines changed

README.md

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,19 @@ Next, update composer from the terminal.
4141
4242
Lastly, publish the config file. You can get your API key from [Steam](http://steamcommunity.com/dev/apikey).
4343

44-
php artisan vendor:publish
44+
php artisan vendor:publish --provider="Syntax\SteamApi\SteamApiServiceProvider"
4545

4646
## Usage
4747

48+
```php
49+
use SteamApi;
50+
51+
/** Get Portal 2 */
52+
$apps = SteamApi::app()->appDetails([620]);
53+
54+
echo $app->first()->name;
55+
```
56+
4857
Each service from the Steam API has its own methods you can use.
4958

5059
- [Global](#global)
@@ -75,7 +84,7 @@ format | string | The format you want back. | No | null
7584
##### Example usage
7685

7786
```php
78-
Steam::convertId($id, $format);
87+
SteamApi::convertId($id, $format);
7988
```
8089

8190
> Example Output: [convertId](./examples/global/convertId.txt)
@@ -84,7 +93,7 @@ Steam::convertId($id, $format);
8493
The [Steam News](https://developer.valvesoftware.com/wiki/Steam_Web_API#GetNewsForApp_.28v0002.29) web api is used to get articles for games.
8594

8695
```php
87-
Steam::news()
96+
SteamApi::news()
8897
```
8998

9099
#### GetNewsForApp
@@ -102,7 +111,7 @@ maxlength | int | The maximum number of characters to return | No | null
102111

103112
```php
104113
<?php
105-
$news = Steam::news()->GetNewsForApp($appId, 5, 500)->newsitems;
114+
$news = SteamApi::news()->GetNewsForApp($appId, 5, 500)->newsitems;
106115
?>
107116
```
108117

@@ -114,7 +123,7 @@ The [Player Service](https://developer.valvesoftware.com/wiki/Steam_Web_API#GetO
114123
When instantiating the player class, you are required to pass a steamId or Steam community ID.
115124

116125
```php
117-
Steam::player($steamId)
126+
SteamApi::player($steamId)
118127
```
119128

120129
#### GetSteamLevel
@@ -178,7 +187,7 @@ The [User](https://developer.valvesoftware.com/wiki/Steam_Web_API#GetFriendList_
178187
When instantiating the user class, you are required to pass at least one steamId or steam community ID.
179188

180189
```php
181-
Steam::user($steamId)
190+
SteamApi::user($steamId)
182191
```
183192

184193
#### ResolveVanityURL
@@ -191,7 +200,7 @@ Name | Type | Description | Required | Default
191200
displayName| string | The display name to get the steam ID for. In `http://steamcommunity.com/id/gabelogannewell` it would be `gabelogannewell`. | Yes | NULL
192201

193202
```php
194-
$player = Steam::user($steamId)->ResolveVanityURL('gabelogannewell');
203+
$player = SteamApi::user($steamId)->ResolveVanityURL('gabelogannewell');
195204
```
196205

197206
> Example Output: [ResolveVanityURL](./examples/user/ResolveVanityURL.txt)
@@ -208,11 +217,11 @@ steamId| int[] | An array of (or singular) steam ID(s) to get details for | No
208217
```php
209218
// One user
210219
$steamId = 76561197960287930;
211-
$player = Steam::user($steamId)->GetPlayerSummaries()[0];
220+
$player = SteamApi::user($steamId)->GetPlayerSummaries()[0];
212221

213222
// Several users
214223
$steamIds = [76561197960287930, 76561197968575517]
215-
$players = Steam::user($steamIds)->GetPlayerSummaries();
224+
$players = SteamApi::user($steamIds)->GetPlayerSummaries();
216225
```
217226

218227
> Example Output: [GetPlayerSummaries](./examples/user/GetPlayerSummaries.txt)
@@ -250,7 +259,7 @@ The [User Stats](https://developer.valvesoftware.com/wiki/Steam_Web_API#GetPlaye
250259
When instantiating the user stats class, you are required to pass a steamID or Steam community ID.
251260

252261
```php
253-
Steam::userStats($steamId)
262+
SteamApi::userStats($steamId)
254263
```
255264

256265
#### GetPlayerAchievements
@@ -306,7 +315,7 @@ appId| int | The ID of the game you want the details for. | Yes |
306315
This area will get details for games.
307316

308317
```php
309-
Steam::app()
318+
SteamApi::app()
310319
```
311320

312321
#### appDetails
@@ -332,7 +341,7 @@ This method will return an array of app objects directly from Steam. It include
332341
This method will get details for packages.
333342

334343
```php
335-
Steam::package()
344+
SteamApi::package()
336345
```
337346

338347
#### packageDetails
@@ -353,7 +362,7 @@ l | string | The l is the language parameter, you can get the appropriate langua
353362
This method will get user inventory for item.
354363

355364
```php
356-
Steam::item()
365+
SteamApi::item()
357366
```
358367

359368
#### GetPlayerItems
@@ -374,7 +383,7 @@ steamid | int | The steamid of the Steam user you want for | Yes |
374383
This service is used to get details on a Steam group.
375384

376385
```php
377-
Steam::group()
386+
SteamApi::group()
378387
```
379388

380389
#### GetGroupSummary
@@ -390,7 +399,7 @@ group| string or int | The ID or the name of the group. | Yes
390399

391400
```php
392401
<?php
393-
$news = Steam::group()->GetGroupSummary('Valve');
402+
$news = SteamApi::group()->GetGroupSummary('Valve');
394403
?>
395404
```
396405

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"ext-json": "*"
2121
},
2222
"require-dev": {
23-
"phpunit/phpunit": "^10.5",
23+
"phpunit/phpunit": "^10.5|^11.0",
2424
"orchestra/testbench": "^8.0",
2525
"vlucas/phpdotenv": "^5.6",
2626
"rector/rector": "^1.0"

src/Syntax/SteamApi/Command/SteamAppGrabber.php

Lines changed: 0 additions & 66 deletions
This file was deleted.

src/Syntax/SteamApi/Steam/Package.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,40 +22,40 @@ public function __construct()
2222
* @throws ApiCallFailedException
2323
* @throws GuzzleException
2424
*/
25-
public function packageDetails($packIds, $cc = null, $language = null): Collection
25+
public function packageDetails($packId, $cc = null, $language = null): Collection
2626
{
2727
// Set up the api details
2828
$this->method = 'packagedetails';
2929
$this->version = null;
3030
// Set up the arguments
3131
$arguments = [
32-
'packageids' => $packIds,
32+
'packageids' => $packId,
3333
'cc' => $cc,
3434
'l' => $language,
3535
];
3636
// Get the client
3737
$client = $this->setUpClient($arguments);
3838

39-
return $this->convertToObjects($client, $packIds);
39+
return $this->convertToObjects($client, $packId);
4040
}
4141

42-
protected function convertToObjects($package, $packIds): Collection
42+
protected function convertToObjects($package, $packId): Collection
4343
{
44-
$convertedPacks = $this->convertPacks($package, $packIds);
44+
$convertedPacks = $this->convertPacks($package, $packId);
4545
return $this->sortObjects($convertedPacks);
4646
}
4747

4848
/**
4949
* @param $packages
50-
* @param $packIds
50+
* @param $packId
5151
* @return Collection
5252
*/
53-
protected function convertPacks($packages, $packIds): Collection
53+
protected function convertPacks($packages, $packId): Collection
5454
{
5555
$convertedPacks = new Collection();
5656
foreach ($packages as $package) {
5757
if (isset($package->data)) {
58-
$convertedPacks->add(new PackageContainer($package->data, $packIds));
58+
$convertedPacks->add(new PackageContainer($package->data, $packId));
5959
}
6060
}
6161

src/Syntax/SteamApi/SteamApiServiceProvider.php

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,16 @@
22

33
namespace Syntax\SteamApi;
44

5-
use Illuminate\Foundation\AliasLoader;
65
use Illuminate\Support\ServiceProvider;
76

87
class SteamApiServiceProvider extends ServiceProvider
98
{
10-
/**
11-
* Indicates if loading of the provider is deferred.
12-
*
13-
* @var bool
14-
*/
15-
protected $defer = false;
16-
179
/**
1810
* Bootstrap the application events.
1911
*
2012
* @return void
2113
*/
22-
public function boot()
14+
public function boot(): void
2315
{
2416
$this->publishes([__DIR__ . '/../../config/config.php' => config_path('steam-api.php')]);
2517
}
@@ -29,32 +21,17 @@ public function boot()
2921
*
3022
* @return void
3123
*/
32-
public function register()
33-
{
34-
$this->registerAlias();
35-
36-
$this->app->singleton('steam-api', fn() => new Client);
37-
}
38-
39-
/**
40-
* Register the alias for package.
41-
*
42-
* @return void
43-
*/
44-
protected function registerAlias()
24+
public function register(): void
4525
{
46-
$this->app->booting(function () {
47-
$loader = AliasLoader::getInstance();
48-
$loader->alias('Steam', \Syntax\SteamApi\Facades\SteamApi::class);
49-
});
26+
$this->app->singleton('steam-api', fn () => new Client());
5027
}
5128

5229
/**
5330
* Get the services provided by the provider.
5431
*
5532
* @return string[]
5633
*/
57-
public function provides()
34+
public function provides(): array
5835
{
5936
return ['steam-api'];
6037
}

tests/PackageTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function it_gets_details_for_an_package_by_id()
2121
/**
2222
* @param $detail
2323
*/
24-
private function checkPackageClasses($detail)
24+
private function checkPackageClasses($detail): void
2525
{
2626
$this->assertInstanceOf(\Syntax\SteamApi\Containers\Package::class, $detail);
2727
}

0 commit comments

Comments
 (0)