Ejemplo n.º 1
0
 /**
  *  Decodes a base64 encoded chat code.
  *
  * @param $code
  * @return ChatLink
  * @throws ChatlinkFormatException
  * @throws UnknownChatlinkTypeException
  * @throws \Exception
  */
 public static function decode($code)
 {
     $data = self::getData($code);
     $chatlinkType = $data[0];
     switch ($chatlinkType) {
         case self::TYPE_ITEM:
             return ItemChatlink::decode($code);
         case self::TYPE_COIN:
             return CoinChatlink::decode($code);
         case self::TYPE_TEXT:
             return TextChatlink::decode($code);
         case self::TYPE_MAP:
             return MapChatlink::decode($code);
         case self::TYPE_SKILL:
             return SkillChatlink::decode($code);
         case self::TYPE_TRAIT:
             return TraitChatlink::decode($code);
         case self::TYPE_RECIPE:
             return RecipeChatlink::decode($code);
         case self::TYPE_SKIN:
             return SkinChatlink::decode($code);
         case self::TYPE_OUTFIT:
             return OutfitChatlink::decode($code);
         case self::TYPE_WVW_OBJECTIVE:
             return WvWObjectiveChatlink::decode($code);
     }
     throw new UnknownChatlinkTypeException("Unknown chat link type ({$chatlinkType})");
 }
Ejemplo n.º 2
0
 public function testItemChatLinkDecodeUpgrades()
 {
     $chatlink = ItemChatlink::decode('[&AgGqtgDgfQ4AAP9fAAAnYAAA]');
     $itemStack = $chatlink->getItemStack();
     $this->assertEquals(1, $itemStack->count, 'ItemChatlink should decode the item count correctly');
     $this->assertEquals(46762, $itemStack->id, 'ItemChatlink should decode the item id correctly');
     $this->assertEquals(3709, $itemStack->skin, 'ItemChatlink should decode the item skin correctly');
     $this->assertEquals([24575, 24615], $itemStack->upgrades, 'ItemChatlink should decode the item upgrades correctly');
 }