/** * 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})"); }
public function testDecode() { $this->assertEquals(1010, TraitChatlink::decode('[&B/IDAAA=]')->getId()); }