diff --git a/README.md b/README.md index 01cfd55..fbeef54 100644 --- a/README.md +++ b/README.md @@ -366,7 +366,7 @@ Name | Type | Description | Required | Default appId| int | The appid of the game you want for | Yes | steamid | int | The steamid of the Steam user you want for | Yes | -⚠️ **Now known to supports**:`440`, `570`, `620`, `730`, `205790`, `221540`, `238460` +⚠️ **Now known to supports**:`440`, `570`, `620`, `205790`, `221540`, `238460` > Example Output: [GetPlayerItems](./examples/item/GetPlayerItems.txt) diff --git a/src/Syntax/SteamApi/Client.php b/src/Syntax/SteamApi/Client.php index 846ca0a..fec7187 100644 --- a/src/Syntax/SteamApi/Client.php +++ b/src/Syntax/SteamApi/Client.php @@ -39,7 +39,7 @@ class Client public $validFormats = ['json', 'xml', 'vdf']; - protected $url = 'http://api.steampowered.com/'; + protected $url = 'https://api.steampowered.com/'; protected $client; @@ -87,7 +87,7 @@ public function getSteamId() * @throws ApiCallFailedException * @throws GuzzleException */ - protected function setUpService($arguments = null) + protected function setUpService($arguments = null): string { // Services have a different url syntax if ($arguments == null) { @@ -183,7 +183,7 @@ public function getRedirectUrl() * @throws ApiCallFailedException * @throws GuzzleException */ - protected function sendRequest(Request $request) + protected function sendRequest(Request $request): stdClass { // Try to get the result. Handle the possible exceptions that can arise try { @@ -191,7 +191,7 @@ protected function sendRequest(Request $request) $result = new stdClass(); $result->code = $response->getStatusCode(); - $result->body = json_decode($response->getBody(true)); + $result->body = json_decode($response->getBody()); } catch (ClientException $e) { throw new ApiCallFailedException($e->getMessage(), $e->getResponse()->getStatusCode(), $e); } catch (ServerException $e) { @@ -204,7 +204,7 @@ protected function sendRequest(Request $request) return $result; } - private function buildUrl($version = false) + private function buildUrl($version = false): string { // Set up the basic url $url = $this->url . $this->interface . '/' . $this->method . '/'; @@ -251,7 +251,7 @@ public function __call($name, $arguments) * * @return Collection */ - protected function sortObjects($objects) + protected function sortObjects(Collection $objects): Collection { return $objects->sortBy(function ($object) { return $object->name; @@ -262,25 +262,25 @@ protected function sortObjects($objects) * @param string $method * @param string $version */ - protected function setApiDetails($method, $version) + protected function setApiDetails(string $method, string $version) { $this->method = $method; $this->version = $version; } - protected function getServiceResponse($arguments) + protected function getServiceResponse($arguments): string { $arguments = json_encode($arguments); // Get the client - return $this->setUpService($arguments)->response; + return $this->setUpService($arguments); } /** * @return string * @throws Exceptions\InvalidApiKeyException */ - protected function getApiKey() + protected function getApiKey(): string { $apiKey = Config::get('steam-api.steamApiKey'); diff --git a/src/Syntax/SteamApi/Command/SteamAppGrabber.php b/src/Syntax/SteamApi/Command/SteamAppGrabber.php index b097f96..e9dc4ef 100644 --- a/src/Syntax/SteamApi/Command/SteamAppGrabber.php +++ b/src/Syntax/SteamApi/Command/SteamAppGrabber.php @@ -45,7 +45,7 @@ public function fire() * * @return array */ - protected function getArguments() + protected function getArguments(): array { return [ ['example', InputArgument::REQUIRED, 'An example argument.'], @@ -57,7 +57,7 @@ protected function getArguments() * * @return array */ - protected function getOptions() + protected function getOptions(): array { return [ ['example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null], diff --git a/src/Syntax/SteamApi/Containers/App.php b/src/Syntax/SteamApi/Containers/App.php index 7d1c8a4..41bdab8 100644 --- a/src/Syntax/SteamApi/Containers/App.php +++ b/src/Syntax/SteamApi/Containers/App.php @@ -61,6 +61,8 @@ class App extends BaseContainer public $movies; + public $screenshots; + public function __construct($app) { @@ -91,10 +93,10 @@ public function __construct($app) $this->achievements = $this->checkIssetField($app, 'achievements', $this->getFakeAchievementsObject()); $this->dlc = $this->checkIssetCollection($app, 'dlc', new Collection()); $this->movies = $this->checkIssetCollection($app, 'movies', new Collection()); - + $this->screenshots = $this->checkIssetCollection($app, 'screenshots', new Collection()); } - protected function getFakeMetacriticObject() + protected function getFakeMetacriticObject(): stdClass { $object = new stdClass(); $object->url = null; @@ -102,14 +104,14 @@ protected function getFakeMetacriticObject() return $object; } - protected function getFakePriceObject() + protected function getFakePriceObject(): stdClass { $object = new stdClass(); $object->final = 'No price found'; return $object; } - protected function getFakeFullgameObject() + protected function getFakeFullgameObject(): stdClass { $object = new stdClass(); $object->appid = null; @@ -117,14 +119,14 @@ protected function getFakeFullgameObject() return $object; } - protected function getFakeRecommendationsObject() + protected function getFakeRecommendationsObject(): stdClass { $object = new stdClass(); $object->total = 0; return $object; } - protected function getFakeAchievementsObject() + protected function getFakeAchievementsObject(): stdClass { $object = new stdClass(); $object->total = 0; diff --git a/src/Syntax/SteamApi/Containers/BaseContainer.php b/src/Syntax/SteamApi/Containers/BaseContainer.php index 852c908..49688d0 100644 --- a/src/Syntax/SteamApi/Containers/BaseContainer.php +++ b/src/Syntax/SteamApi/Containers/BaseContainer.php @@ -9,11 +9,11 @@ abstract class BaseContainer /** * @param $app * @param string $field - * @param mixed $value + * @param mixed $value * * @return mixed */ - protected function checkIsNullField($app, $field, $value = null) + protected function checkIsNullField($app, string $field, $value = null) { return ! is_null($app->$field) ? $app->$field : $value; } @@ -21,11 +21,11 @@ protected function checkIsNullField($app, $field, $value = null) /** * @param $app * @param string $field - * @param mixed $value + * @param mixed $value * * @return mixed */ - protected function checkIssetField($app, $field, $value = null) + protected function checkIssetField($app, string $field, $value = null) { return isset($app->$field) ? $app->$field : $value; } @@ -33,11 +33,11 @@ protected function checkIssetField($app, $field, $value = null) /** * @param $app * @param string $field - * @param mixed $value + * @param mixed $value * * @return mixed */ - protected function checkIssetCollection($app, $field, $value = null) + protected function checkIssetCollection($app, string $field, $value = null): Collection { return isset($app->$field) ? new Collection($app->$field) : $value; } @@ -47,7 +47,7 @@ protected function checkIssetCollection($app, $field, $value = null) * * @return string */ - protected function getImageForAvatar($image) + protected function getImageForAvatar(string $image): string { return '<img src="' . $image . '" />'; } @@ -61,7 +61,7 @@ protected function getImageForAvatar($image) * * @return string */ - protected function pluralize($word, $count) + protected function pluralize($word, $count): string { if ((int) $count === 1) { return $word .' '; @@ -77,7 +77,7 @@ protected function pluralize($word, $count) * * @return string */ - protected function convertFromMinutes($minutes) + protected function convertFromMinutes($minutes): string { $seconds = $minutes * 60; diff --git a/src/Syntax/SteamApi/Containers/Game.php b/src/Syntax/SteamApi/Containers/Game.php index 8b0ac8d..12823aa 100644 --- a/src/Syntax/SteamApi/Containers/Game.php +++ b/src/Syntax/SteamApi/Containers/Game.php @@ -34,26 +34,26 @@ public function __construct($app) $this->playtimeForeverReadable = $this->convertFromMinutes($this->playtimeForever); $this->icon = $this->checkIssetImage($app, 'img_icon_url'); $this->logo = $this->checkIssetImage($app, 'img_logo_url'); - $this->header = 'http://cdn.akamai.steamstatic.com/steam/apps/' . $this->appId . '/header.jpg'; + $this->header = 'https://cdn.akamai.steamstatic.com/steam/apps/' . $this->appId . '/header.jpg'; $this->hasCommunityVisibleStats = $this->checkIssetField($app, 'has_community_visible_stats', 0); } /** * @param $app * @param string $field - * @param string $value + * @param null $value * * @return null|string */ - protected function checkIssetImage($app, $field, $value = null) + protected function checkIssetImage($app, string $field, $value = null): ?string { return isset($app->$field) ? $this->getImageForGame($app->appid, $app->$field) : $value; } - protected function getImageForGame($appId, $hash) + protected function getImageForGame($appId, $hash): ?string { if ($hash != null) { - return 'http://media.steampowered.com/steamcommunity/public/images/apps/' . $appId . '/' . $hash . '.jpg'; + return 'https://media.steampowered.com/steamcommunity/public/images/apps/' . $appId . '/' . $hash . '.jpg'; } return null; diff --git a/src/Syntax/SteamApi/Containers/Id.php b/src/Syntax/SteamApi/Containers/Id.php index 5a077e1..74271c9 100644 --- a/src/Syntax/SteamApi/Containers/Id.php +++ b/src/Syntax/SteamApi/Containers/Id.php @@ -19,7 +19,7 @@ class Id /** * @param integer $id */ - function __construct($id) + function __construct(int $id) { $client = new Client; diff --git a/src/Syntax/SteamApi/Containers/Package.php b/src/Syntax/SteamApi/Containers/Package.php index bb7148d..efd9186 100644 --- a/src/Syntax/SteamApi/Containers/Package.php +++ b/src/Syntax/SteamApi/Containers/Package.php @@ -31,7 +31,7 @@ public function __construct($package, $id) $this->release = $package->release_date; } - protected function getFakePriceObject() + protected function getFakePriceObject(): \stdClass { $object = new \stdClass(); $object->final = 'No price found'; diff --git a/src/Syntax/SteamApi/Containers/Player.php b/src/Syntax/SteamApi/Containers/Player.php index 5848b05..cfc3332 100644 --- a/src/Syntax/SteamApi/Containers/Player.php +++ b/src/Syntax/SteamApi/Containers/Player.php @@ -94,7 +94,7 @@ public function __construct($player) } } - protected function getLocation() + protected function getLocation(): \stdClass { $countriesFile = json_decode(\file_get_contents(__DIR__ . '/../Resources/countries.json')); $result = new \stdClass; @@ -116,7 +116,7 @@ protected function getLocation() return $result; } - protected function convertPersonaState($personaState) + protected function convertPersonaState($personaState): string { switch ($personaState) { case 0: diff --git a/src/Syntax/SteamApi/Exceptions/UnrecognizedId.php b/src/Syntax/SteamApi/Exceptions/UnrecognizedId.php index 7967d97..97de8f4 100644 --- a/src/Syntax/SteamApi/Exceptions/UnrecognizedId.php +++ b/src/Syntax/SteamApi/Exceptions/UnrecognizedId.php @@ -9,7 +9,7 @@ class UnrecognizedId extends \Exception * @param int $code * @param null $previous */ - public function __construct($message, $code = 0, $previous = null) + public function __construct(string $message, $code = 0, $previous = null) { parent::__construct($message, $code, $previous); } diff --git a/src/Syntax/SteamApi/Facades/SteamApi.php b/src/Syntax/SteamApi/Facades/SteamApi.php index 86a07d7..4173e7d 100644 --- a/src/Syntax/SteamApi/Facades/SteamApi.php +++ b/src/Syntax/SteamApi/Facades/SteamApi.php @@ -11,7 +11,7 @@ class SteamApi extends Facade * * @return string */ - protected static function getFacadeAccessor() + protected static function getFacadeAccessor(): string { return 'steam-api'; } diff --git a/src/Syntax/SteamApi/Steam/App.php b/src/Syntax/SteamApi/Steam/App.php index 6d13203..898aca2 100644 --- a/src/Syntax/SteamApi/Steam/App.php +++ b/src/Syntax/SteamApi/Steam/App.php @@ -15,17 +15,17 @@ class App extends Client public function __construct() { parent::__construct(); - $this->url = 'http://store.steampowered.com/'; + $this->url = 'https://store.steampowered.com/'; $this->interface = 'api'; } /** - * @param $appIds + * @param $appId * @param null $country * @param null $language * @return Collection */ - public function appDetails($appIds, $country = null, $language = null) + public function appDetails($appId, $country = null, $language = null) { // Set up the api details $this->method = 'appdetails'; @@ -33,7 +33,7 @@ public function appDetails($appIds, $country = null, $language = null) // Set up the arguments $arguments = [ - 'appids' => $appIds, + 'appids' => $appId, 'cc' => $country, 'l' => $language, ]; @@ -47,7 +47,7 @@ public function appDetails($appIds, $country = null, $language = null) public function GetAppList() { // Set up the api details - $this->url = 'http://api.steampowered.com/'; + $this->url = 'https://api.steampowered.com/'; $this->interface = 'ISteamApps'; $this->method = __FUNCTION__; $this->version = 'v0001'; diff --git a/src/Syntax/SteamApi/Steam/Group.php b/src/Syntax/SteamApi/Steam/Group.php index 2a2ed5f..3353a06 100644 --- a/src/Syntax/SteamApi/Steam/Group.php +++ b/src/Syntax/SteamApi/Steam/Group.php @@ -13,9 +13,9 @@ public function GetGroupSummary($group) $this->method = 'memberslistxml'; if (is_numeric($group)) { - $this->url = 'http://steamcommunity.com/gid/'; + $this->url = 'https://steamcommunity.com/gid/'; } else { - $this->url = 'http://steamcommunity.com/groups/'; + $this->url = 'https://steamcommunity.com/groups/'; } $this->url = $this->url . $group; diff --git a/src/Syntax/SteamApi/Steam/Item.php b/src/Syntax/SteamApi/Steam/Item.php index 3cd77f8..a4389d7 100644 --- a/src/Syntax/SteamApi/Steam/Item.php +++ b/src/Syntax/SteamApi/Steam/Item.php @@ -13,7 +13,7 @@ class Item extends Client public function __construct() { parent::__construct(); - $this->url = 'http://store.steampowered.com/'; + $this->url = 'https://store.steampowered.com/'; $this->isService = true; $this->interface = 'api'; } @@ -21,7 +21,7 @@ public function __construct() public function GetPlayerItems($appId, $steamId) { // Set up the api details - $this->url = 'http://api.steampowered.com/'; + $this->url = 'https://api.steampowered.com/'; $this->interface = 'IEconItems_' . $appId; $this->method = __FUNCTION__; $this->version = 'v0001'; diff --git a/src/Syntax/SteamApi/Steam/Package.php b/src/Syntax/SteamApi/Steam/Package.php index 999332a..2daa94e 100644 --- a/src/Syntax/SteamApi/Steam/Package.php +++ b/src/Syntax/SteamApi/Steam/Package.php @@ -11,11 +11,11 @@ class Package extends Client public function __construct() { parent::__construct(); - $this->url = 'http://store.steampowered.com/'; + $this->url = 'https://store.steampowered.com/'; $this->interface = 'api'; } - public function packageDetails($packIds, $cc = null, $language = null) + public function packageDetails($packIds, $cc = null, $language = null): Collection { // Set up the api details $this->method = 'packagedetails'; diff --git a/src/Syntax/SteamApi/Steam/Player.php b/src/Syntax/SteamApi/Steam/Player.php index 553cd89..6612cf0 100644 --- a/src/Syntax/SteamApi/Steam/Player.php +++ b/src/Syntax/SteamApi/Steam/Player.php @@ -31,16 +31,20 @@ public function GetSteamLevel() return $client->player_level; } - public function GetPlayerLevelDetails() + public function GetPlayerLevelDetails(): ?Level { $details = $this->GetBadges(); + if(count((array) $details) == 0) { + return null; + } + $details = new Level($details); return $details; } - public function GetBadges() + public function GetBadges(): string { // Set up the api details $this->setApiDetails(__FUNCTION__, 'v0001'); @@ -52,7 +56,7 @@ public function GetBadges() return $this->getServiceResponse($arguments); } - public function GetCommunityBadgeProgress($badgeId = null) + public function GetCommunityBadgeProgress($badgeId = null): string { // Set up the api details $this->setApiDetails(__FUNCTION__, 'v0001'); @@ -94,7 +98,7 @@ public function GetOwnedGames($includeAppInfo = true, $includePlayedFreeGames = return $this->convertToObjects(isset($client->games) ? $client->games : []); } - public function GetRecentlyPlayedGames($count = null) + public function GetRecentlyPlayedGames($count = null): ?Collection { // Set up the api details $this->setApiDetails(__FUNCTION__, 'v0001'); @@ -133,7 +137,7 @@ public function IsPlayingSharedGame($appIdPlaying) return $client->lender_steamid; } - protected function convertToObjects($games) + protected function convertToObjects($games): Collection { $convertedGames = $this->convertGames($games); @@ -142,7 +146,7 @@ protected function convertToObjects($games) return $games; } - private function convertGames($games) + private function convertGames($games): Collection { $convertedGames = new Collection; diff --git a/src/Syntax/SteamApi/Steam/User.php b/src/Syntax/SteamApi/Steam/User.php index 7852774..2ffe715 100644 --- a/src/Syntax/SteamApi/Steam/User.php +++ b/src/Syntax/SteamApi/Steam/User.php @@ -57,7 +57,7 @@ public function ResolveVanityURL($displayName = null) * * @return array */ - public function GetPlayerSummaries($steamId = null) + public function GetPlayerSummaries($steamId = null): array { // Set up the api details $this->method = __FUNCTION__; @@ -76,7 +76,7 @@ public function GetPlayerSummaries($steamId = null) return $this->compressPlayerSummaries($map); } - private function getChunkedPlayerSummaries($chunk) + private function getChunkedPlayerSummaries($chunk): array { // Set up the arguments $arguments = [ @@ -123,7 +123,7 @@ public function GetPlayerBans($steamId = null) return $client->players; } - public function GetFriendList($relationship = 'all', $summaries = true) + public function GetFriendList($relationship = 'all', $summaries = true): array { // Set up the api details $this->method = __FUNCTION__; @@ -158,7 +158,7 @@ public function GetFriendList($relationship = 'all', $summaries = true) return $friends; } - protected function convertToObjects($players) + protected function convertToObjects($players): array { $cleanedPlayers = []; diff --git a/src/Syntax/SteamApi/Steam/User/Stats.php b/src/Syntax/SteamApi/Steam/User/Stats.php index 4bf0790..5041d27 100644 --- a/src/Syntax/SteamApi/Steam/User/Stats.php +++ b/src/Syntax/SteamApi/Steam/User/Stats.php @@ -22,7 +22,7 @@ public function __construct($steamId) * * @return array */ - public function GetPlayerAchievementsAPI($appId) + public function GetPlayerAchievementsAPI($appId): ?array { // Set up the api details $this->method = 'GetPlayerAchievementsAPI'; @@ -50,16 +50,16 @@ public function GetPlayerAchievementsAPI($appId) return $this->convertToObjects($client->achievements, $stats); } - public function GetPlayerAchievements($appId) + public function GetPlayerAchievements($appId): ?array { // Set up the api details $this->interface = null; $this->method = 'achievements'; if (is_numeric($this->steamId)) { - $this->url = 'http://steamcommunity.com/profiles/'; + $this->url = 'https://steamcommunity.com/profiles/'; } else { - $this->url = 'http://steamcommunity.com/id/'; + $this->url = 'https://steamcommunity.com/id/'; } $this->url = $this->url . $this->steamId . '/stats/' . $appId; @@ -121,7 +121,7 @@ public function GetGlobalAchievementPercentagesForApp($gameId) * * @return mixed */ - public function GetUserStatsForGame($appId, $all = false) + public function GetUserStatsForGame(int $appId, $all = false) { // Set up the api details $this->method = __FUNCTION__; @@ -168,7 +168,7 @@ public function GetSchemaForGame($appId) return $this->setUpClient($arguments); } - protected function convertToObjects($achievements) + protected function convertToObjects($achievements): array { $cleanedAchievements = []; diff --git a/src/Syntax/SteamApi/SteamApiServiceProvider.php b/src/Syntax/SteamApi/SteamApiServiceProvider.php index 7750f1b..9c8a005 100644 --- a/src/Syntax/SteamApi/SteamApiServiceProvider.php +++ b/src/Syntax/SteamApi/SteamApiServiceProvider.php @@ -56,7 +56,7 @@ protected function registerAlias() * * @return string[] */ - public function provides() + public function provides(): array { return ['steam-api']; } diff --git a/src/Syntax/SteamApi/SteamId.php b/src/Syntax/SteamApi/SteamId.php index 7c23f92..1d2bb1f 100644 --- a/src/Syntax/SteamApi/SteamId.php +++ b/src/Syntax/SteamApi/SteamId.php @@ -89,7 +89,7 @@ private function convertToID3() $this->formatted->{self::$ID3} = $formatted; } - private function determineIDType($id) + private function determineIDType($id): array { $id = trim($id); diff --git a/src/config/config.php b/src/config/config.php index 17aeb4d..97841a5 100644 --- a/src/config/config.php +++ b/src/config/config.php @@ -9,7 +9,7 @@ | | This value is used for authenticating with the Steam API. You can generate | an API key by visiting the following link and completing the form - | http://steamcommunity.com/dev/apikey. + | https://steamcommunity.com/dev/apikey. | | Once you have generated your API key, add it to your 'env' file. |