Convert a token to the proper ptg value.

@access private
@param mixed $token The token to convert.
@return mixed the converted token on success. PEAR_Error if the token
is not recognized
334148
function _convert($token)
    {
        if (preg_match("/^\"[^\"]{0,255}\"$/", $token)) {
            return $this->_convertString($token);

        } elseif (is_numeric($token)) {
            return $this->_convertNumber($token);

        // match references like A1 or $A$1
        } elseif (preg_match('/^\$?([A-Ia-i]?[A-Za-z])\$?(\d+)$/',$token)) {
            return $this->_convertRef2d($token);

        // match external references like Sheet1!A1 or Sheet1:Sheet2!A1
        } elseif (preg_match("/^\w+(\:\w+)?\![A-Ia-i]?[A-Za-z](\d+)$/u",$token)) {
            return $this->_convertRef3d($token);

        // match external references like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1
        } elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\![A-Ia-i]?[A-Za-z](\d+)$/u",$token)) {
            return $this->_convertRef3d($token);

        // match ranges like A1:B2
        } elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)\:(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)$/",$token)) {
            return $this->_convertRange2d($token);

        // match ranges like A1..B2
        } elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)$/",$token)) {
            return $this->_convertRange2d($token);

        // match external ranges like Sheet1!A1 or Sheet1:Sheet2!A1:B2
        } elseif (preg_match("/^\w+(\:\w+)?\!([A-Ia-i]?[A-Za-z])?(\d+)\:([A-Ia-i]?[A-Za-z])?(\d+)$/u",$token)) {
            return $this->_convertRange3d($token);

        // match external ranges like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1:B2
        } elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\!([A-Ia-i]?[A-Za-z])?(\d+)\:([A-Ia-i]?[A-Za-z])?(\d+)$/u",$token)) {
            return $this->_convertRange3d($token);

        // operators (including parentheses)
        } elseif (isset($this->ptg[$token])) {
            return pack("C", $this->ptg[$token]);

        // commented so argument number can be processed correctly. See toReversePolish().
        /*elseif (preg_match("/[A-Z0-9\xc0-\xdc\.]+/",$token))
        {
            return($this->_convertFunction($token,$this->_func_args));
        }*/

        // if it's an argument, ignore the token (the argument remains)
        } elseif ($token == 'arg') {
            return '';
        }
        // TODO: use real error codes
        return $this->raiseError("Unknown token $token");
    }
1175962
public function decode($token)
    {
        try {
            $data = JWT::decode($token, $this->secretKey, $this->allowed_algs);
        } catch (\UnexpectedValueException $e) {
            throw new \UnexpectedValueException($e->getMessage());
        } catch (\DomainException $e) {
            throw new \UnexpectedValueException($e->getMessage());
        }

        if ($data->exp < time()) {
            throw new \UnexpectedValueException('token not allowed');
        }

        return $data;
    }
531282
public function toUser($token = false)
    {
        $payload = $this->getPayload($token);

        if (! $user = $this->user->getBy($this->identifier, $payload['sub'])) {
            return false;
        }

        return $user;
    }
859191
public static function getTokenName($token)
    {
        if (is_int($token[self::T_KEY])) {
            return token_name($token[self::T_KEY]);
        } else {
            return $token[self::T_KEY];
        }
    }
737600
public function parse(Token $token)
    {
        $variable = substr($token->getValue(), 1);

        if ('current' === $variable) {
            return new FunctionCallValue(
                'current',
                [new ValueForCurrentValue()]
            );
        }

        try {
            return new VariableValue($variable);
        } catch (TypeError $error) {
            throw ExpressionLanguageExceptionFactory::createForUnparsableToken($token, 0, $error);
        }
    }
1132889
public function moveToToken(Token $token) {

      if (!$token->isValid()) {
        $this->setValid(false);
        return new Token();
      }

      $tokenIndex = $token->getIndex();


      foreach ($this->collection as $index => $collectionToken) {
        if ($collectionToken->getIndex() === $tokenIndex) {
          $this->setPosition($index);
          return $collectionToken;
        }
      }

      $this->setValid(false);
      return new Token();
    }
1368450
protected function _setToken($token)
    {
        //Prevents an empty value is serialized
        if (!$token) {
            return $token;
        }
        $token = is_string($token) ? $token : serialize($token);

        return substr(Security::hash($token, 'sha1', Configure::read('Tokens.tokenSalt')), 0, 25);
    }
1080788
public function parse(Token $token)
    {
        $value = $this->tokenizer->detokenize($token->getValue());
        $realValue = preg_replace('/^<\((.*)\)>$/', '<identity($1)>', $value);

        return $this->decoratedTokenParser->parse(
            new Token($realValue, new TokenType(TokenType::FUNCTION_TYPE))
        );
    }
677037
public function stem($token) 
    {
        if(array_key_exists($token, $this->dictionary)){
            return $this->dictionary[$token];
        }
        return $token;
    }
535252
private function decrypt(string $token): string
    {
        $serializer = new JWECompactSerializer(new StandardConverter());
        $jwe = $serializer->unserialize($token);
        $this->encryptionHeaderCheckerManager->check($jwe, 0);
        if (false === $this->jweLoader->decryptUsingKeySet($jwe, $this->encryptionKeyset, 0)) {
            throw new JWTDecodeFailureException('decoding_error', 'An error occurred while trying to decrypt the JWT token.');
        }

        return $jwe->getPayload();
    }
534849
public function withToken(Token $token)
    {
        $card = $this->with('token', $token);

        if (null !== $card->number) {
            $lastDigits = strlen($card->number) <= 4
                ? $card->number :
                substr($card->number, -4);
            $card->number = "XXXX-XXXX-XXXX-" . $lastDigits;
        }

        $card->cvv = null;

        return $card;
    }
100719
function _convert($token)
	{
		if (preg_match("/\"([^\"]|\"\"){0,255}\"/", $token)) {
			return $this->_convertString($token);

		} elseif (is_numeric($token)) {
			return $this->_convertNumber($token);

		// match references like A1 or $A$1
		} elseif (preg_match('/^\$?([A-Ia-i]?[A-Za-z])\$?(\d+)$/',$token)) {
			return $this->_convertRef2d($token);

		// match external references like Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1
		} elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?(\d+)$/u",$token)) {
			return $this->_convertRef3d($token);

		// match external references like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1
		} elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?(\d+)$/u",$token)) {
			return $this->_convertRef3d($token);

		// match ranges like A1:B2 or $A$1:$B$2
		} elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)\:(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)$/', $token)) {
			return $this->_convertRange2d($token);

		// match external ranges like Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2
		} elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)\:\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)$/u",$token)) {
			return $this->_convertRange3d($token);

		// match external ranges like 'Sheet1'!A1:B2 or 'Sheet1:Sheet2'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1:Sheet2'!$A$1:$B$2
		} elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)\:\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)$/u",$token)) {
			return $this->_convertRange3d($token);

		// operators (including parentheses)
		} elseif (isset($this->ptg[$token])) {
			return pack("C", $this->ptg[$token]);

        // match error codes
		} elseif (preg_match("/^#[A-Z0\/]{3,5}[!?]{1}$/", $token) or $token == '#N/A') {
		    return $this->_convertError($token);

		// commented so argument number can be processed correctly. See toReversePolish().
		/*elseif (preg_match("/[A-Z0-9\xc0-\xdc\.]+/",$token))
		{
			return($this->_convertFunction($token,$this->_func_args));
		}*/

		// if it's an argument, ignore the token (the argument remains)
		} elseif ($token == 'arg') {
			return '';
		}

		// TODO: use real error codes
		throw new PHPExcel_Writer_Exception("Unknown token $token");
	}
1212134
protected function getUserByToken($token)
    {
        \Php\Support\Helpers\Arr::arrayReplaceByTemplate($this->guzzle, ['{{%TOKEN%}}' => $token]);

        $response = $this->getHttpClient()->get($this->getDriverConfig('userInfoUrl'), $this->guzzle);

        return json_decode($response->getBody(), true);
    }
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;
        }
    }
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;
    }
1155279
protected function stringIsEndOfLimitClause($token)
    {
        return $this->clauseLimit
        && $token[Tokenizer::TOKEN_VALUE] !== ','
        && $token[Tokenizer::TOKEN_TYPE] !== Tokenizer::TOKEN_TYPE_NUMBER
        && $token[Tokenizer::TOKEN_TYPE] !== Tokenizer::TOKEN_TYPE_WHITESPACE;
    }
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;
    }