コード例 #1
0
 /**
  * Extract basic profile data from an array.
  *
  * @param array $params The parameters with the API response where the data should be extracted from.
  * @return array
  */
 public static function extractCharacterData($params)
 {
     $characters = array();
     foreach ($params['characters'] as $character) {
         $characters[] = BasicProfileParsingService::extract($character);
     }
     return $characters;
 }
コード例 #2
0
 /**
  * Extract ladder position entry from an array.
  *
  * @param array $params
  * @return Position
  */
 public static function extract($params)
 {
     $ladderPosition = new Position();
     $characterProfile = BasicProfileParsingService::extract($params['character']);
     $joinDate = new \DateTime();
     $joinDate->setTimestamp($params['joinTimestamp']);
     if (!isset($params['favoriteRaceP1'])) {
         $params['favoriteRaceP1'] = null;
     }
     $ladderPosition->setCharacter($characterProfile)->setJoinDate($joinDate)->setPoints($params['points'])->setWins($params['wins'])->setLosses($params['losses'])->setHighestRank($params['highestRank'])->setPreviousRank($params['previousRank'])->setFavoriteRaceP1($params['favoriteRaceP1']);
     return $ladderPosition;
 }
 /**
  * Extract complete player profile information from an array.
  *
  * @param array $params
  * @return Player
  */
 public static function extract($params)
 {
     $portrait = IconParsingService::extract($params['portrait']);
     $career = CareerParsingService::extract($params['career']);
     $playerSwarmLevels = SwarmLevelsParsingService::extract($params['swarmLevels']);
     $campaign = CampaignParsingService::extract($params['campaign']);
     $season = SeasonParsingService::extract($params['season']);
     $rewards = RewardsParsingService::extract($params['rewards']);
     $achievements = AchievementParsingService::extract($params['achievements']);
     $profileBasicInformation = BasicProfileParsingService::extract($params);
     $player = new Player();
     $player->setBasicInformation($profileBasicInformation)->setPortrait($portrait)->setCareer($career)->setSwarmLevels($playerSwarmLevels)->setCampaign($campaign)->setSeason($season)->setRewards($rewards)->setAchievements($achievements);
     return $player;
 }