Use previously generated token.

@param string $tokenString
@param array $options
@return Token
516581
public static function useExisting(string $tokenString, array $options): Token
    {
        $token = new self($options);
        $token->token = $tokenString;

        return $token;
    }
693748
protected function setOptions($options = null)
    {
        if ($options instanceof TokenInterface) {
            $this->_owner = UserSecurityIdentity::fromToken($options);
        }

        return $this;
    }
1250745
public function input($options = [])
    {
        if (is_string($options)) {
            $options = ['class' => $options];
        }

        $input = new Input($this->expression('input'), $options);

        return $input;
    }
413131
public static function create(array $tokens, array $options) {
        HashMap::assert($tokens, 'tokens');

        $format    = Format::create($options);
        $operation = SqlOperation::create($tokens);

        if ($operation === SqlOperations::INSERT) return $format->encode(InsertChangeSet::create($tokens));
        if ($operation === SqlOperations::UPDATE) return $format->encode(UpdateChangeSet::create($tokens));

        return null;
    }
918428
public static function parse(Parser $parser, TokensList $list, array $options = [])
    {
        $ret = [];

        $expr = new self();

        /**
         * The state of the parser.
         *
         * Below are the states of the parser.
         *
         *      0 ---------------------[ old name ]--------------------> 1
         *
         *      1 ------------------------[ TO ]-----------------------> 2
         *
         *      2 ---------------------[ new name ]--------------------> 3
         *
         *      3 ------------------------[ , ]------------------------> 0
         *      3 -----------------------[ else ]----------------------> (END)
         *
         * @var int
         */
        $state = 0;

        for (; $list->idx < $list->count; ++$list->idx) {
            /**
             * Token parsed at this moment.
             *
             * @var Token
             */
            $token = $list->tokens[$list->idx];

            // End of statement.
            if ($token->type === Token::TYPE_DELIMITER) {
                break;
            }

            // Skipping whitespaces and comments.
            if (($token->type === Token::TYPE_WHITESPACE) || ($token->type === Token::TYPE_COMMENT)) {
                continue;
            }

            if ($state === 0) {
                $expr->old = Expression::parse(
                    $parser,
                    $list,
                    [
                        'breakOnAlias' => true,
                        'parseField' => 'table',
                    ]
                );
                if (empty($expr->old)) {
                    $parser->error(
                        'The old name of the table was expected.',
                        $token
                    );
                }
                $state = 1;
            } elseif ($state === 1) {
                if ($token->type === Token::TYPE_KEYWORD && $token->keyword === 'TO') {
                    $state = 2;
                } else {
                    $parser->error(
                        'Keyword "TO" was expected.',
                        $token
                    );
                    break;
                }
            } elseif ($state === 2) {
                $expr->new = Expression::parse(
                    $parser,
                    $list,
                    [
                        'breakOnAlias' => true,
                        'parseField' => 'table',
                    ]
                );
                if (empty($expr->new)) {
                    $parser->error(
                        'The new name of the table was expected.',
                        $token
                    );
                }
                $state = 3;
            } elseif ($state === 3) {
                if (($token->type === Token::TYPE_OPERATOR) && ($token->value === ',')) {
                    $ret[] = $expr;
                    $expr = new self();
                    $state = 0;
                } else {
                    break;
                }
            }
        }

        if ($state !== 3) {
            $parser->error(
                'A rename operation was expected.',
                $list->tokens[$list->idx - 1]
            );
        }

        // Last iteration was not saved.
        if (! empty($expr->old)) {
            $ret[] = $expr;
        }

        --$list->idx;

        return $ret;
    }
850778
private function grabAttribsBeforeMethodToken(Tokens $tokens, $index)
    {
        static $tokenAttribsMap = [
            T_PRIVATE   => 'visibility',
            T_PROTECTED => 'visibility',
            T_PUBLIC    => null, // destroy T_PUBLIC token. This is literally the only change from the original
            T_ABSTRACT  => 'abstract',
            T_FINAL     => 'final',
            T_STATIC    => 'static',
        ];

        return $this->grabAttribsBeforeToken(
            $tokens,
            $index,
            $tokenAttribsMap,
            [
                'abstract'   => null,
                'final'      => null,
                'visibility' => null,
                'static'     => null,
            ]
        );
    }
752165
protected function parseFlagOption($optionString)
    {
        for ($i = 0; $i < strlen($optionString); $i++) {
            $optionChar = substr($optionString, $i, 1);
            $optionParts = explode('=', substr($optionString, $i + 1));

            if (count($optionParts) > 1 && empty($optionParts[0])) {
                $value = $optionParts[1];
            } elseif ($optionChar !== "=") {
                $value = true;
            } else {
                break;
            }

            $this->flagOptions[$optionChar] = $value;
        }
        return $this;
    }
475960
public function generateToken($data, $options = array())
    {
        return $this->encodeToken(
            $this->buildClaims($options + array('data' => $data)),
            $this->secret
        );
    }
1114783
public function resend($tokenString)
    {
        $token = $this->findToken($tokenString);

        if (! is_null($token)) {
            session()->forget('inactive_email');

            $token->user->resendInvite();
        }
    }
156220
public static function parse(Parser $parser, TokensList $list, array $options = [])
    {
        $ret = new self();

        /**
         * The state of the parser.
         *
         * Below are the states of the parser.
         *
         *      0 ----------------------[ name ]-----------------------> 1
         *
         *      1 --------------------[ parameters ]-------------------> (END)
         *
         * @var int
         */
        $state = 0;

        for (; $list->idx < $list->count; ++$list->idx) {
            /**
             * Token parsed at this moment.
             *
             * @var Token
             */
            $token = $list->tokens[$list->idx];

            // End of statement.
            if ($token->type === Token::TYPE_DELIMITER) {
                break;
            }

            // Skipping whitespaces and comments.
            if (($token->type === Token::TYPE_WHITESPACE) || ($token->type === Token::TYPE_COMMENT)) {
                continue;
            }

            if ($state === 0) {
                $ret->name = $token->value;
                $state = 1;
            } elseif ($state === 1) {
                if (($token->type === Token::TYPE_OPERATOR) && ($token->value === '(')) {
                    $ret->parameters = ArrayObj::parse($parser, $list);
                }
                break;
            }
        }

        return $ret;
    }
18337
public static function invoke(
        array $options,
        string $code
    ): string {
        $codes = Property::getArray(
            $options,
            self::OPTION_CODES,
            null
        );

        if (empty($codes)) {
            return $code;
        }

        return Property::getString(
            $codes,
            $code,
            $code
        );
    }
879536
public function create($token, array $options = [])
    {
        $entity = new Token(compact('token'));

        foreach (['user_id', 'type', 'extra', 'expiry'] as $key) {
            if (array_key_exists($key, $options)) {
                $entity->set($key, $options[$key]);
            }
        }

        if (!$this->getTable()->save($entity)) {
            $field = collection(array_keys($entity->getErrors()))->first();
            $error = collection(collection(($entity->getErrors()))->first())->first();

            throw new LogicException(sprintf('Error for `%s` field: %s', $field, lcfirst($error)));
        }

        return $entity->token;
    }
125402
public static function generateToken(array $options): string
    {
        $issuedAt = time();
        $expire = $issuedAt + $options['expiration_sec']; // tempo de expiracao do token

        $tokenParam = [
            'iat' => $issuedAt, // timestamp de geracao do token
            'iss' => $options['host'], // dominio, pode ser usado para descartar tokens de outros dominios
            'exp' => $expire, // expiracao do token
            'nbf' => $issuedAt - 1, // token nao eh valido Antes de
            'data' => $options['userdata'], // Dados do usuario logado
        ];

        return JWT::encode($tokenParam, cfg::SALT_KEY);
    }
500731
public static function parse(Parser $parser, TokensList $list, array $options = [])
    {
        $ret = [];

        /**
         * The state of the parser.
         *
         * Below are the states of the parser.
         *
         *      0 ----------------------[ array ]---------------------> 1
         *
         *      1 ------------------------[ , ]------------------------> 0
         *      1 -----------------------[ else ]----------------------> (END)
         *
         * @var int
         */
        $state = 0;

        for (; $list->idx < $list->count; ++$list->idx) {
            /**
             * Token parsed at this moment.
             *
             * @var Token
             */
            $token = $list->tokens[$list->idx];

            // End of statement.
            if ($token->type === Token::TYPE_DELIMITER) {
                break;
            }

            // Skipping whitespaces and comments.
            if (($token->type === Token::TYPE_WHITESPACE) || ($token->type === Token::TYPE_COMMENT)) {
                continue;
            }

            if (($token->type === Token::TYPE_KEYWORD)
                && ($token->flags & Token::FLAG_KEYWORD_RESERVED)
                && ((~$token->flags & Token::FLAG_KEYWORD_FUNCTION))
                && ($token->value !== 'DUAL')
                && ($token->value !== 'NULL')
                && ($token->value !== 'CASE')
            ) {
                // No keyword is expected.
                break;
            }

            if ($state === 0) {
                if ($token->type === Token::TYPE_KEYWORD
                    && $token->value === 'CASE'
                ) {
                    $expr = CaseExpression::parse($parser, $list, $options);
                } else {
                    $expr = Expression::parse($parser, $list, $options);
                }

                if ($expr === null) {
                    break;
                }
                $ret[] = $expr;
                $state = 1;
            } elseif ($state === 1) {
                if ($token->value === ',') {
                    $state = 0;
                } else {
                    break;
                }
            }
        }

        if ($state === 0) {
            $parser->error(
                'An expression was expected.',
                $list->tokens[$list->idx]
            );
        }

        --$list->idx;

        return $ret;
    }
552828
public function translate($string, array $args = [], array $options = [])
    {
        $translation = new TranslationManager(new LanguageDefault([]));

        return new TranslatableMarkup($string, $args, $options, $translation);
    }
728519
protected function createRoleModel($token, array $options = [])
    {
        $role = $this->newRoleModel($token, $options);
        $role->save();

        return $role;
    }
1002508
public static function parse(Parser $parser, TokensList $list, array $options = [])
    {
        $ret = [];
        $expr = new self();
        $expr->type = isset($options['type']) ? $options['type'] : null;
        /**
         * The state of the parser.
         *
         * Below are the states of the parser.
         *      0 ----------------- [ USE/IGNORE/FORCE ]-----------------> 1
         *      1 -------------------- [ INDEX/KEY ] --------------------> 2
         *      2 ----------------------- [ FOR ] -----------------------> 3
         *      2 -------------------- [ expr_list ] --------------------> 0
         *      3 -------------- [ JOIN/GROUP BY/ORDER BY ] -------------> 4
         *      4 -------------------- [ expr_list ] --------------------> 0
         * @var int
         */
        $state = 0;

        // By design, the parser will parse first token after the keyword. So, the keyword
        // must be analyzed too, in order to determine the type of this index hint.
        if ($list->idx > 0) {
            --$list->idx;
        }
        for (; $list->idx < $list->count; ++$list->idx) {
            /**
             * Token parsed at this moment.
             *
             * @var Token
             */
            $token = $list->tokens[$list->idx];

            // End of statement.
            if ($token->type === Token::TYPE_DELIMITER) {
                break;
            }
            // Skipping whitespaces and comments.
            if (($token->type === Token::TYPE_WHITESPACE) || ($token->type === Token::TYPE_COMMENT)) {
                continue;
            }

            switch ($state) {
                case 0:
                    if ($token->type === Token::TYPE_KEYWORD) {
                        if ($token->keyword === 'USE' || $token->keyword === 'IGNORE' || $token->keyword === 'FORCE') {
                            $expr->type = $token->keyword;
                            $state = 1;
                        } else {
                            break 2;
                        }
                    }
                    break;
                case 1:
                    if ($token->type === Token::TYPE_KEYWORD) {
                        if ($token->keyword === 'INDEX' || $token->keyword === 'KEY') {
                            $expr->indexOrKey = $token->keyword;
                        } else {
                            $parser->error('Unexpected keyword.', $token);
                        }
                        $state = 2;
                    } else {
                        // we expect the token to be a keyword
                        $parser->error('Unexpected token.', $token);
                    }
                    break;
                case 2:
                    if ($token->type === Token::TYPE_KEYWORD && $token->keyword === 'FOR') {
                        $state = 3;
                    } else {
                        $expr->indexes = ExpressionArray::parse($parser, $list);
                        $state = 0;
                        $ret[] = $expr;
                        $expr = new self();
                    }
                    break;
                case 3:
                    if ($token->type === Token::TYPE_KEYWORD) {
                        if ($token->keyword === 'JOIN' || $token->keyword === 'GROUP BY' || $token->keyword === 'ORDER BY') {
                            $expr->for = $token->keyword;
                        } else {
                            $parser->error('Unexpected keyword.', $token);
                        }
                        $state = 4;
                    } else {
                        // we expect the token to be a keyword
                        $parser->error('Unexpected token.', $token);
                    }
                    break;
                case 4:
                    $expr->indexes = ExpressionArray::parse($parser, $list);
                    $state = 0;
                    $ret[] = $expr;
                    $expr = new self();
                    break;
            }
        }
        --$list->idx;

        return $ret;
    }