コード例 #1
0
 public function testItemChatLinkEncodeUpgrades()
 {
     $itemStack = ItemStack::fromArray(['count' => 1, 'id' => 46762, 'skin' => 3709, 'upgrades' => [24575, 24615]]);
     $chatlink = new ItemChatlink($itemStack);
     $chatcode = $chatlink->encode();
     $this->assertEquals('[&AgGqtgDgfQ4AAP9fAAAnYAAA]', $chatcode, 'ItemChatlink should encode the ItemStack correctly');
 }
コード例 #2
0
ファイル: Chatlink.php プロジェクト: gw2treasures/gw2tools
 /**
  *  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})");
 }