Reads a single line of data from the stream.

@param  string $token
@throws TeamSpeak3_Transport_Exception
@return TeamSpeak3_Helper_String
966415
public function readLine($token = "\n")
  {
    $this->connect();

    $line = TeamSpeak3_Helper_String::factory("");

    while(!$line->endsWith($token))
    {
      $this->waitForReadyRead();

      $data = @fgets($this->stream, 4096);

      TeamSpeak3_Helper_Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "DataRead", $data);

      if($data === FALSE)
      {
        if($line->count())
        {
          $line->append($token);
        }
        else
        {
          throw new TeamSpeak3_Transport_Exception("connection to server '" . $this->config["host"] . ":" . $this->config["port"] . "' lost");
        }
      }
      else
      {
        $line->append($data);
      }
    }

    return $line->trim();
  }
496887
public function decodeToken($token)
    {
        try {
            $parser = new Parser();

            if (!$token = $parser->parse((string) $token)) {
                throw new Exception('Token inválido');
            }

            return $token;
        } catch (Exception $e) {
            abort(401, 'Favor efetuar o login novamente');
        }
    }
1152292
public function readToken(): Token
    {
        if ($this->isEnd()) {
            throw new LogicException("The end of buffer is reached");
        }
        $token = $this->getTokenAtIndex($this->cursor);
        $this->cursor++;
        return $token;
    }
343418
public function decode($token)
    {
        $jwt = new JWT();

        try {
            $decoded = Codec::decode($token, $this->secret, ['HS256']);
        } catch (\Firebase\JWT\SignatureInvalidException $e) {
            $jwt->setSignatureValid(false);
        } catch (\Exception $e) {
        }

        list($header, $payload, $signature) = explode(".", $token);
        $header    = base64_decode($header);
        $payload   = json_decode(base64_decode($payload));
        $signature = base64_decode($signature);

        // Retrieves start and end public claims other claims are going to be ignored
        $jwt->setStart(new \DateTime('@'.$payload->nbf));
        $jwt->setEnd(new \Datetime('@'.$payload->exp));

        // Retrieves private claims
        foreach ($payload->data as $key => $value) {
            $jwt->set($key, $value);
        }

        return $jwt;
    }
429547
public function parse(Token $token)
    {
        $lineno = $token->getLine();
        $stream = $this->parser->getStream();

        $stream->expect(Token::BLOCK_END_TYPE);
        $try = $this->parser->subparse([$this, 'decideCatch']);
        $stream->next();
        $stream->expect(Token::BLOCK_END_TYPE);
        $catch = $this->parser->subparse([$this, 'decideEnd']);
        $stream->next();
        $stream->expect(Token::BLOCK_END_TYPE);

        return new TwigNodeTryCatch($try, $catch, $lineno, $this->getTag());
    }
906483
protected function checkToken($token)
    {
        if (!$token) {
            return false;
        }

        $file = $this->pathForToken($token);
        $content = null;

        if (file_exists($file)) {
            $content = file_get_contents($file);
            unlink($file);
        }

        return $content === $token;
    }
265225
public function getToken(string $token)
    {
        /* @var \ZfrOAuth2\Server\Model\AbstractToken $tokenFromDb */
        $tokenFromDb = $this->tokenRepository->findByToken($token);

        // Because the collation is most often case insensitive, we need to add a check here to ensure
        // that the token matches case
        if (! $tokenFromDb || ! hash_equals($tokenFromDb->getToken(), $token)) {
            return null;
        }

        return $tokenFromDb;
    }
720228
public function streamsFollowed($token = null)
    {
        $token = $this->getToken($token);

        $streams = $this->client->get('https://api.twitch.tv/kraken/streams/followed?oauth_token=' . $token);

        return $streams->json();
    }
1239544
public function decode($token)
    {
        try {
            $jws = JWS::load($token);
        } catch (Exception $e) {
            throw new TokenInvalidException('Could not decode token: '.$e->getMessage());
        }

        if (! $jws->verify($this->secret, $this->algo)) {
            throw new TokenInvalidException('Token Signature could not be verified.');
        }

        return $jws->getPayload();
    }
901000
public static function isOperator($token)
    {
        if (!\is_string($token)) {
            return false;
        }

        return \strpos(self::MISC_OPERATORS, $token) !== false;
    }
985261
public function decode($token)
    {
        if (\substr_count($token, '.') < 2) {
            throw new JWTException('Invalid token: Incomplete segments', static::ERROR_TOKEN_INVALID);
        }

        $token = \explode('.', $token, 3);
        $this->validateHeader((array) $this->urlSafeDecode($token[0]));

        // Validate signature.
        if (!$this->verify($token[0] . '.' . $token[1], $token[2])) {
            throw new JWTException('Invalid token: Signature failed', static::ERROR_SIGNATURE_FAILED);
        }

        $payload = (array) $this->urlSafeDecode($token[1]);

        $this->validateTimestamps($payload);

        return $payload;
    }
793476
public static function fromString(string $token): self
    {
        $instance = new self();
        $instance->token = $token;

        $parsed = explode('.', $token);
        if (count($parsed) !== 3) {
            throw new InvalidArgumentException('PbjxToken string is invalid.');
        }

        $instance->header = json_decode(self::urlsafeB64Decode($parsed[0]), true);
        $instance->payload = json_decode(self::urlsafeB64Decode($parsed[1]), true);
        $instance->signature = self::urlsafeB64Decode($parsed[2]);
        $instance->checkClaims();

        $instance->payload['exp'] = (int)$instance->payload['exp'];
        $instance->payload['iat'] = (int)$instance->payload['iat'];

        return $instance;
    }
215703
static public function load($token = null)
    {
        // if single token is set, we keep it
        if (is_null($token) && static::hasSingleToken()) {
            $token = static::getSingleToken();
        }

        // if no session are set, we set a new one only is class has a singleToken
        if (!Session::has($token)){
            if (static::hasSingleToken()) {
                Session::push($token, json_encode(['constructor' => static::class]));
            } else {
                throw new \InvalidArgumentException('Token "' . $token . '" is not valid');
            }
        }

        // load configuration
        $config = Session::get($token);
        $config = json_decode($config[0], true);
        $constructor = $config['constructor'];

        // construct Table polliwog
        if (preg_match('#(?<class>.+)::(?<method>.+)#', $constructor, $match)) {

            $method = $match['method'];
            // extract parameters
            $params = [];
            if (preg_match('#(?<method>[^:]+):(?<params>.+)#', $method, $params)) {
                $method = $params['method'];
                $params = explode(',', $params['params']);
            }

            $table =  call_user_func_array([$match['class'], $method], $params);
        } else {
            $instance = new \ReflectionClass($config->constructor);
            $table = $instance->newInstance();
        }

        // validate that instance is viable
        if (!($table instanceof static)) {
            throw new \Exception('Loaded instance is not viable');
        }

        return $table;
    }
447705
public function decryptToken(string $token)
    {
        $tokenData = false;
        $encrypted = base64_decode($token);

        if ($encrypted) {
            $serialized = Security::decrypt($encrypted, Configure::read('Security.cryptKey'));
            $tokenData = unserialize($serialized);
        }

        return $tokenData;
    }
1275442
public function parse(Token $token): string
    {
        $value = $token->getValue();
        if ('' === $value) {
            throw ExpressionLanguageExceptionFactory::createForUnparsableToken($token);
        }

        return $this->tokenizer->detokenize(substr($value, 1));
    }
569765
protected function _decode($token)
    {
        $config = $this->_config;
        try {
            $payload = JWT::decode(
                $token,
                $config['key'] ?: Security::getSalt(),
                $config['allowedAlgs']
            );

            return $payload;
        } catch (Exception $e) {
            if (Configure::read('debug')) {
                throw $e;
            }
            $this->_error = $e;
        }
    }
1007516
private function ConsumeChar( $token )
	{
		$curr = new CurrentToken();
		$curr->token = $token;
		$curr->value = null;
		$curr->anchor = $this->m_anchor;
		$curr->length = 1;
		array_push( $this->m_token, $curr );
	}