/** * @dataProvider tokenProvider */ public function testGetToken($token, $tokenExpected, $subdictExpected) { $subdict = false; $ret = TokenMap::getToken($token, $subdict); $this->assertEquals($tokenExpected, $ret); $this->assertEquals($subdictExpected, $subdict); }
protected function getTokenDouble($n, $n2) { $pos = $n2 + $n * 256; $ret = ''; $subdict = true; TokenMap::GetToken($pos, $subdict, $ret); if (!$ret) { throw new Exception("BinTreeNodeReader->getToken: Invalid token {$pos}({$n} + {$n} * 256)"); } return $ret; }
protected function writeString($tag) { $intVal = -1; $subdict = false; if (TokenMap::TryGetToken($tag, $subdict, $intVal)) { if ($subdict) { $this->writeToken(236); } $this->writeToken($intVal); return; } $index = strpos($tag, '@'); if ($index) { $server = substr($tag, $index + 1); $user = substr($tag, 0, $index); $this->writeJid($user, $server); } else { $this->writeBytes($tag); } }
protected function getToken($token) { $ret = ""; $subdict = false; TokenMap::GetToken($token, $subdict, $ret); if (!$ret) { $token = $this->readInt8(); TokenMap::GetToken($token, $subdict, $ret); if (!$ret) { return false; } } return $ret; }
/** * @param $token * @return string * @throws \InvalidArgumentException */ protected function getToken($token) { $ret = ''; $subdict = false; TokenMap::GetToken($token, $subdict, $ret); if (!$ret) { $token = $this->readInt8(); TokenMap::GetToken($token, $subdict, $ret); if (!$ret) { throw new \InvalidArgumentException('BinTreeNodeReader->getToken: Invalid token ' . $token); } } return $ret; }