/** * This checks the cache for an existing inventory. If it exists it is * returned. Otherwise a new inventory is created. * * @param int $appId The application ID of the game * @param string $steamId The 64bit Steam ID or the vanity URL of the user * @param bool $fetchNow Whether the data should be fetched now * @param bool $bypassCache Whether the cache should be bypassed * @return GameInventory */ public static function create($appId, $steamId, $fetchNow = true, $bypassCache = false) { if (is_numeric($steamId)) { $steamId64 = $steamId; } else { $steamId64 = SteamId::resolveVanityUrl($steamId); } switch ($appId) { case DotA2BetaInventory::APP_ID: $inventoryClass = 'Dota2\\Dota2BetaInventory'; break; case DotA2Inventory::APP_ID: $inventoryClass = 'Dota2\\Dota2Inventory'; break; case Portal2Inventory::APP_ID: $inventoryClass = 'Portal2\\Portal2Inventory'; break; case TF2BetaInventory::APP_ID: $inventoryClass = 'TF2\\TF2BetaInventory'; break; case TF2Inventory::APP_ID: $inventoryClass = 'TF2\\TF2Inventory'; break; default: $inventoryClass = 'GameInventory'; } self::overwriteClass("\\SteamCondenser\\Community\\{$inventoryClass}"); return self::createCacheable($appId, $steamId64, $fetchNow, $bypassCache); }
/** * This checks the cache for an existing inventory. If it exists it is * returned. Otherwise a new inventory is created. * * @param int $appId The application ID of the game * @param string $steamId The 64bit Steam ID or the vanity URL of the user * @param bool $fetchNow Whether the data should be fetched now * @param bool $bypassCache Whether the cache should be bypassed * @return GameInventory */ public static function create($appId, $steamId, $fetchNow = true, $bypassCache = false) { if (is_numeric($steamId)) { $steamId64 = $steamId; } else { $steamId64 = SteamId::resolveVanityUrl($steamId); } if (self::isCached($appId, $steamId64) && !$bypassCache) { $inventory = self::$cache[$appId][$steamId64]; if ($fetchNow && !$inventory->isFetched()) { $inventory->fetch(); } return $inventory; } else { switch ($appId) { case Dota2BetaInventory::APP_ID: $inventoryClass = 'Dota2\\Dota2BetaInventory'; break; case Dota2Inventory::APP_ID: $inventoryClass = 'Dota2\\Dota2Inventory'; break; case Portal2Inventory::APP_ID: $inventoryClass = 'Portal2\\Portal2Inventory'; break; case TF2BetaInventory::APP_ID: $inventoryClass = 'TF2\\TF2BetaInventory'; break; case TF2Inventory::APP_ID: $inventoryClass = 'TF2\\TF2Inventory'; break; default: $inventoryClass = 'GameInventory'; } $inventoryClass = "\\SteamCondenser\\Community\\{$inventoryClass}"; return new $inventoryClass($appId, $steamId64, $fetchNow); } }