Ejemplo n.º 1
0
 /**
  * @dataProvider tokenProvider
  */
 public function testGetToken($token, $tokenExpected, $subdictExpected)
 {
     $subdict = false;
     $ret = TokenMap::getToken($token, $subdict);
     $this->assertEquals($tokenExpected, $ret);
     $this->assertEquals($subdictExpected, $subdict);
 }
Ejemplo n.º 2
0
 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);
     }
 }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 5
0
 /**
  * @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;
 }