Пример #1
0
 /**
  * @param $arrayRawGamesRated
  */
 public static function getRatedRelatedArrays($arrayRawGamesRated)
 {
     $arrayGameRated = [];
     if (isset($arrayRawGamesRated['item'])) {
         $arrayRawGamesRated = Utility::bggGetMultiple($arrayRawGamesRated);
         foreach ($arrayRawGamesRated['item'] as $game) {
             if (isset($game['stats']['rating']['@attributes']['value']) && $game['stats']['rating']['@attributes']['value'] != 'N/A') {
                 $rating = $game['stats']['rating']['@attributes']['value'];
             } else {
                 $rating = 0;
             }
             $thumbnail = isset($game['thumbnail']) ? $game['thumbnail'] : '';
             $minplayers = isset($game['minplayers']) ? $game['minplayers'] : '';
             $maxplayers = isset($game['maxplayers']) ? $game['maxplayers'] : '';
             $arrayGameRated[$game['@attributes']['objectid']] = ['id' => $game['@attributes']['objectid'], 'name' => $game['name'], 'thumbnail' => $thumbnail, 'minplayer' => $minplayers, 'maxplayer' => $maxplayers, 'playingtime' => isset($game['stats']['@attributes']['playingtime']) ? $game['stats']['@attributes']['playingtime'] : 0, 'rating' => $rating];
         }
     }
     $GLOBALS['data']['gamesRated'] = $arrayGameRated;
 }
Пример #2
0
 public static function getDetailOwned(&$arrayRawGamesOwned)
 {
     $arrayGamesDetails = [];
     if (isset($arrayRawGamesOwned['item'])) {
         foreach ($arrayRawGamesOwned['item'] as $key => $game) {
             $arrayId[] = $game['@attributes']['objectid'];
             $arrayRawGamesOwned['item'][$key]['detail'] = [];
         }
     }
     $arrayChunk = array_chunk($arrayId, 40, true);
     foreach ($arrayChunk as $key => $arrayIds) {
         $strIds = implode(',', $arrayIds);
         $urlBGG = BGGUrls::getDetail($strIds);
         $fromBGG = self::getBGGUrl($urlBGG);
         $fromBGG = Utility::bggGetMultiple($fromBGG);
         foreach ($fromBGG['item'] as $gameDetail) {
             $arrayGamesDetails[$gameDetail['@attributes']['id']] = $gameDetail;
         }
     }
     return $arrayGamesDetails;
 }