public function testGetJSON()
 {
     $webApi = $this->getMockBuilder('\\SteamCondenser\\Community\\WebApi')->setMethods(['_load'])->disableOriginalConstructor()->getMock();
     $webApi->expects($this->once())->method('_load')->with('json', 'interface', 'method', 2, ['test' => 'param']);
     $this->instance->setValue($webApi);
     WebApi::getJSON('interface', 'method', 2, ['test' => 'param']);
 }
 public function testGetJSON()
 {
     $webApi = $this->getMockBuilder('WebApi')->setMethods(array('_load'))->disableOriginalConstructor()->getMock();
     $webApi->expects($this->once())->method('_load')->with('json', 'interface', 'method', 2, array('test' => 'param'));
     $this->instance->setValue($webApi);
     WebApi::getJSON('interface', 'method', 2, array('test' => 'param'));
 }
 /**
  * Loads the news for the given game with the given restrictions
  *
  * @param int $appId The unique Steam Application ID of the game (e.g. 440
  *        for Team Fortress 2). See
  *        http://developer.valvesoftware.com/wiki/Steam_Application_IDs for
  *        all application IDs
  * @param int $count The maximum number of news to load (default: 5).
  *        There's no reliable way to load all news. Use really a really
  *        great number instead
  * @param int $maxLength The maximum content length of the news (default:
  *        null). If a maximum length is defined, the content of the news
  *        will only be at most <var>maxLength</var> characters long plus an
  *        ellipsis
  * @return array An array of news items for the specified game with the
  *         given options
  */
 public static function getNewsForApp($appId, $count = 5, $maxLength = null)
 {
     $params = array('appid' => $appId, 'count' => $count, 'maxlength' => $maxLength);
     $data = json_decode(WebApi::getJSON('ISteamNews', 'GetNewsForApp', 2, $params));
     $newsItems = array();
     foreach ($data->appnews->newsitems as $newsData) {
         $newsItems[] = new AppNews($appId, $newsData);
     }
     return $newsItems;
 }
 /**
  * Loads the global unlock percentages of all achievements for the given
  * game
  *
  * @param int $appId The unique Steam Application ID of the game (e.g.
  *        <var>440</var> for Team Fortress 2). See
  *        http://developer.valvesoftware.com/wiki/Steam_Application_IDs for
  *        all application IDs
  * @return array The symbolic achievement names with the corresponding
  *         global unlock percentages
  * @throws WebApiException if a request to Steam's Web API fails
  */
 public static function getGlobalPercentages($appId)
 {
     $params = array('gameid' => $appId);
     $data = json_decode(WebApi::getJSON('ISteamUserStats', 'GetGlobalAchievementPercentagesForApp', 2, $params));
     $percentages = array();
     foreach ($data->achievementpercentages->achievements as $achievementData) {
         $percentages[$achievementData->name] = (double) $achievementData->percent;
     }
     return $percentages;
 }
 /**
  * Returns all Golden Wrenches
  *
  * @return All Golden Wrenches
  * @throws SteamCondenserException If an error occurs querying the Web API
  *                                 or the Steam Community
  */
 public static function getGoldenWrenches()
 {
     if (self::$goldenWrenches == null) {
         self::$goldenWrenches = array();
         $data = json_decode(WebApi::getJSON('ITFItems_440', 'GetGoldenWrenches', 2));
         foreach ($data->results->wrenches as $wrenchData) {
             self::$goldenWrenches[] = new TF2GoldenWrench($wrenchData);
         }
     }
     return self::$goldenWrenches;
 }
 /**
  * Resolves a vanity URL of a Steam Community profile to a 64bit numeric
  * SteamID
  *
  * @param string $vanityUrl The vanity URL of a Steam Community profile
  * @return string The 64bit SteamID for the given vanity URL
  * @throws WebApiException if the request to Steam's Web API fails
  */
 public static function resolveVanityUrl($vanityUrl)
 {
     $params = array('vanityurl' => $vanityUrl);
     $json = WebApi::getJSON('ISteamUser', 'ResolveVanityURL', 1, $params);
     $result = json_decode($json);
     $result = $result->response;
     if ($result->success != 1) {
         return null;
     }
     return $result->steamid;
 }
 /**
  * Returns the overall number of players currently playing this game
  *
  * @return int The number of players playing this game
  */
 public function getPlayerCount()
 {
     $params = array('appid' => $this->appId);
     $result = WebApi::getJSON('ISteamUserStats', 'GetNumberOfCurrentPlayers', 1, $params);
     $result = json_decode($result);
     return $result->response->player_count;
 }