Пример #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})");
 }
Пример #2
0
 public function testDecode()
 {
     $this->assertEquals(2, SkinChatlink::decode('[&CgIAAAA=]')->getId());
     $this->assertEquals(1079, SkinChatlink::decode('[&CjcEAAA=]')->getId());
     $this->assertEquals(5743, SkinChatlink::decode('[&Cm8WAAA=]')->getId());
 }