Exemplo n.º 1
0
 public function setUp()
 {
     // Create profile
     $this->profile = new Profile();
     // Create and add Habbo
     $habbo = new Habbo();
     $habbo->parse(self::$data['user']);
     $this->profile->setHabbo($habbo);
     // Create and add all Badge
     foreach (self::$data['badges'] as $badge_data) {
         $badge = new Badge();
         $badge->parse($badge_data);
         $this->profile->addBadge($badge);
     }
     // Create and add all Groups
     foreach (self::$data['groups'] as $group_data) {
         $group = new Group();
         $group->parse($group_data);
         $this->profile->addGroup($group);
     }
     // Create and add all Friends
     foreach (self::$data['friends'] as $friend_data) {
         $friend = new Habbo();
         $friend->parse($friend_data);
         $this->profile->addFriend($friend);
     }
     // Create and add all Rooms
     foreach (self::$data['rooms'] as $room_data) {
         $room = new Room();
         $room->parse($room_data);
         $this->profile->addRoom($room);
     }
 }
Exemplo n.º 2
0
 public function testAllForExceptions()
 {
     foreach (self::$data['badges'] as $data) {
         $entity = new Badge();
         $entity->parse($data);
         // Make sure it doesn't throw errors
         $this->assertInstanceOf('HabboAPI\\Entities\\Badge', $entity);
     }
 }
Exemplo n.º 3
0
 /** Parses habbo info array to \Entities\Habbo object
  *
  * @param array $data
  */
 public function parse($data)
 {
     // These attributes are shared between Habbo and Friends
     $this->setId($data['uniqueId']);
     $this->setHabboName($data['name']);
     $this->setMotto($data['motto']);
     $this->setFigureString($data['figureString']);
     // These could be missing..
     if (isset($data['memberSince'])) {
         $this->setMemberSince($data['memberSince']);
     }
     if (isset($data['profileVisible'])) {
         $this->setProfileVisible($data['profileVisible']);
     }
     if (isset($data['selectedBadges'])) {
         foreach ($data['selectedBadges'] as $badge) {
             $selectedBadge = new Badge();
             $selectedBadge->parse($badge);
             $this->addSelectedBadge($selectedBadge);
         }
     }
 }
Exemplo n.º 4
0
 /**
  * Parses the Habbo Profile endpoints
  *
  * Return an associative array including a Habbo entity and 4 arrays with Group, Friend, Room, Badge entities
  *
  * @param string $id
  * @return array
  */
 public function parseProfile($id)
 {
     // Collect JSON
     $data = $this->_callUrl($this->api_base . "users/" . $id . "/profile");
     // Habbo
     $habbo = new Habbo();
     $habbo->parse($data['user']);
     // Friends
     $friends = array();
     foreach ($data['friends'] as $friend) {
         $temp_friend = new Habbo();
         $temp_friend->parse($friend);
         $friends[] = $temp_friend;
         unset($temp_friend);
     }
     // Groups
     $groups = array();
     foreach ($data['groups'] as $group) {
         $temp_group = new Group();
         $temp_group->parse($group);
         $groups[] = $temp_group;
         unset($temp_group);
     }
     // Rooms
     $rooms = array();
     foreach ($data['rooms'] as $room) {
         $temp_room = new Room();
         $temp_room->parse($room);
         $rooms[] = $temp_room;
         unset($temp_room);
     }
     // Badges
     $badges = array();
     foreach ($data['badges'] as $badge) {
         $temp_badge = new Badge();
         $temp_badge->parse($badge);
         $badges[] = $temp_badge;
         unset($temp_badge);
     }
     // Return it all..
     return array("habbo" => $habbo, "friends" => $friends, "groups" => $groups, "rooms" => $rooms, "badges" => $badges);
 }
Exemplo n.º 5
0
 /**
  * Parses the Habbo Profile endpoints
  *
  * Return an associative array including a Habbo entity and 4 arrays with Group, Friend, Room, Badge entities
  *
  * @param string $id
  * @return array
  */
 public function parseProfile($id)
 {
     // Collect JSON
     list($data) = $this->_callUrl($this->api_base . '/api/public/users/' . $id . '/profile', true);
     // Create Profile entity
     $profile = new Profile();
     // Habbo
     $habbo = new Habbo();
     $habbo->parse($data['user']);
     $profile->setHabbo($habbo);
     // Friends
     foreach ($data['friends'] as $friend) {
         $temp_friend = new Habbo();
         $temp_friend->parse($friend);
         $profile->addFriend($temp_friend);
     }
     // Groups
     foreach ($data['groups'] as $group) {
         $temp_group = new Group();
         $temp_group->parse($group);
         $profile->addGroup($temp_group);
     }
     // Rooms
     foreach ($data['rooms'] as $room) {
         $temp_room = new Room();
         $temp_room->parse($room);
         $profile->addRoom($temp_room);
     }
     // Badges
     foreach ($data['badges'] as $badge) {
         $temp_badge = new Badge();
         $temp_badge->parse($badge);
         $profile->addBadge($temp_badge);
     }
     // Return the Profile
     return $profile;
 }