public function testDecode()
 {
     $this->assertEquals(258, TextChatlink::decode('[&AwIBAAA=]')->getId());
     $this->assertEquals(51200, TextChatlink::decode('[&AwDIAAA=]')->getId());
     $this->assertEquals(10000, TextChatlink::decode('[&AxAnAAA=]')->getId());
     $this->assertEquals(359, TextChatlink::decode('[&A2cBAAA=]')->getId());
 }
Beispiel #2
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})");
 }