Lookup a token type.

@param type $findThis	(str) searches the "token_type" column for this.

@return int				token_type_id that was found; default 0 (unknown)
@throws exception
350456
public function lookup_token_type($findThis) {
		$retval = 0;
		$sql = "SELECT * FROM cswal_token_type_table WHERE token_type=:type";
		
		try {
			$numrows = $this->db->run_query($sql, array('type'=> $findThis));
			
			if($numrows == 1) {
				$data = $this->db->get_single_record();
				$retval = $data['token_type_id'];
			}
		} catch (Exception $ex) {
			throw new exception(__METHOD__ .": failed to retrieve token type::: ". $ex->getMessage());
		}
		
		return $retval;
	}
569888
public function findBySha1($sha1Hash)
    {
        $query = $this->createQuery();
        $query->matching($query->equals('sha1', $sha1Hash));
        $resources = $query->execute()->toArray();
        foreach ($this->addedResources as $importedResource) {
            if ($importedResource->getSha1() === $sha1Hash) {
                $resources[] = $importedResource;
            }
        }

        return $resources;
    }
748689
public function readByValue(string $tokenValue, int $expirationInSeconds): ?TokenInterface
    {
        $schema = $this->getDatabaseSchema();
        return $this->readEnabledTokenByColumnWithExpirationCheck(
            $tokenValue,
            $schema->getTokensValueColumn(),
            $expirationInSeconds,
            $schema->getTokensValueCreatedAtColumn()
        );
    }
408260
public function lookaheadTypeIsAnyOf(array $types): bool
    {
        return isset($this->tokens[$this->position]) && $this->tokens[$this->position]->typeEqualsAnyOf($types);
    }
280786
public function match($token)
    {
        $lookaheadType = $this->lexer->lookahead['type'];

        // Short-circuit on first condition, usually types match
        if ($lookaheadType === $token) {
            $this->lexer->moveNext();

            return;
        }

        // If parameter is not identifier (1-99) must be exact match
        if ($token < Lexer::T_IDENTIFIER) {
            $this->syntaxError($this->lexer->getLiteral($token));
        }

        // If parameter is keyword (200+) must be exact match
        if ($token > Lexer::T_IDENTIFIER) {
            $this->syntaxError($this->lexer->getLiteral($token));
        }

        // If parameter is T_IDENTIFIER, then matches T_IDENTIFIER (100) and keywords (200+)
        if ($token === Lexer::T_IDENTIFIER && $lookaheadType < Lexer::T_IDENTIFIER) {
            $this->syntaxError($this->lexer->getLiteral($token));
        }

        $this->lexer->moveNext();
    }
85659
public function findSeat(Player $findPlayer): int
    {
        return $this->players()
            ->filter(function (Player $player) use ($findPlayer) {
                return $player->equals($findPlayer);
            })
            ->keys()
            ->first();
    }
146754
public function find($token)
    {
        $this->_validateId($token);
        try {
            $path = $this->_config->merchantPath() . '/payment_methods/paypal_account/' . $token;
            $response = $this->_http->get($path);
            return PayPalAccount::factory($response['paypalAccount']);
        } catch (Exception\NotFound $e) {
            throw new Exception\NotFound(
                'paypal account with token ' . $token . ' not found'
            );
        }

    }
954460
public function readByRefresh(string $refreshValue, int $expirationInSeconds): ?TokenInterface
    {
        $schema = $this->getDatabaseSchema();
        return $this->readEnabledTokenByColumnWithExpirationCheck(
            $refreshValue,
            $schema->getTokensRefreshColumn(),
            $expirationInSeconds,
            $schema->getTokensRefreshCreatedAtColumn()
        );
    }
262045
public function getToken($pId = 0)
    {
        if (isset($this->tokens[$pId])) {
            return $this->tokens[$pId];
        } else {
            throw new PHPExcel_Calculation_Exception("Token with id $pId does not exist.");
        }
    }
791283
public function fetchToken(string $token) : ?Token
    {
        return $this->getModel()
                    ->newQuery()
                    ->where('token', $token)
                    ->first();
    }
844108
function checkShash(i) {
  const start = i;
  let l;

  if (i >= tokensLength) return 0;

  if (tokens[i].type === TokenType.NumberSign) i++;
  else return 0;

  if (l = checkIdentOrInterpolation(i) || checkPartialIdent(i)) i += l;
  else return 0;

  while (i < tokensLength) {
    if (l = checkIdentOrInterpolation(i) || checkPartialIdent(i)) i += l;
    else break;
  }

  tokens[start].shashEnd = i;

  return i - start;
}
1002602
protected function parseCreateIndex(SQLTokenIterator $tokens)
    {

        /* @var $entity CreateIndexStatement */
        $entity = new CreateIndexStatement();

        ### FLAGS

        if ($tokens->isToken(SqlToken::T_UNIQUE(), TokenIterator::PREVIOUS, [SqlToken::T_PRIMARY()])) {
            $entity->setIsUnique(true);
        }

        if ($tokens->isToken(SqlToken::T_PRIMARY(), TokenIterator::PREVIOUS, [SqlToken::T_UNIQUE()])) {
            $entity->setIsPrimary(true);
        }

        ### NAME

        if (!$tokens->seekTokenNum(T_STRING)) {
            throw new MalformedSqlException("Missing valid index-name!", $tokens);
        }

        $entity->setName($tokens->getCurrentTokenString());

        ### USING

        if ($tokens->seekTokenNum(SqlToken::T_USING())) {
            switch(true){

                // TODO: R-TREE index not implemented yet!
                case $tokens->seekTokenNum(SqlToken::T_RTREE()):
                case $tokens->seekTokenNum(SqlToken::T_BTREE()):
                    $entity->setIndexType(IndexType::BTREE());
                    break;

                case $tokens->seekTokenNum(SqlToken::T_HASH()):
                    $entity->setIndexType(IndexType::HASH());
                    break;

                default:
                    throw new MalformedSqlException("Invalid index-type specified!", $tokens);
            }
        }

        ### TABLE

        if (!$tokens->seekTokenNum(SqlToken::T_ON())) {
            throw new MalformedSqlException("Missing T_ON for CREATE INDEX statement!", $tokens);
        }

        if (!$this->tableParser->canParseTokens($tokens)) {
            throw new MalformedSqlException("Missing valid table-specifier for CREATE INDEX statement!", $tokens);
        }

        $entity->setTable($this->tableParser->convertSqlToJob($tokens));

        ### COLUMNS

        if (!$tokens->seekTokenText('(')) {
            throw new MalformedSqlException("Missing beginning parenthesis holding columns in CREATE INDEX statement!", $tokens);
        }

        do {
            if (!$this->columnParser->canParseTokens($tokens)) {
                throw new MalformedSqlException("Missing valid column-specifier in CREATE INDEX statement!", $tokens);
            }

            $column = $this->columnParser->convertSqlToJob($tokens);

            $length = null;
            if ($tokens->seekTokenText('(')) {
                if (!$this->valueParser->canParseTokens($tokens)) {
                    throw new MalformedSqlException("Missing valid column-length in CREATE INDEX statement!", $tokens);
                }

                $length = $this->valueParser->convertSqlToJob($tokens);

                if (!$tokens->seekTokenText(')')) {
                    throw new MalformedSqlException("Missing closing parenthesis holding column-length in CREATE INDEX statement!", $tokens);
                }
            }

            $direction = null;
            if ($tokens->seekTokenNum(SqlToken::T_ASC())) {
                $direction = SqlToken::T_ASC();
            } elseif ($tokens->seekTokenNum(SqlToken::T_DESC())) {
                $direction = SqlToken::T_DESC();
            }

            $entity->addColumn($column, $length, $direction);

        } while ($tokens->seekTokenText(','));

        if (!$tokens->seekTokenText(')')) {
            throw new MalformedSqlException("Missing closing parenthesis holding columns in CREATE INDEX statement!", $tokens);
        }

        ### WITH PARSER

        if ($tokens->seekTokenNum(SqlToken::T_WITH())) {
            if (!$tokens->seekTokenNum(SqlToken::T_PARSER())) {
                throw new MalformedSqlException("Missing T_PARSER after T_WITH in CREATE INDEX statement!", $tokens);
            }

            if (!$tokens->seekTokenNum(T_STRING)) {
                throw new MalformedSqlException("Missing valid parser name after WITH PARSER in CREATE INDEX statement!", $tokens);
            }

            $entity->setParser($tokens->getCurrentTokenString());
        }

        return $entity;
    }
59736
private function findIn(array $collection, $index, $pattern)
    {
        $total = count($collection);
        while ($index < $total) {
            $found = $this->match($pattern, $collection, $index++);
            if ($found !== false) {
                $token = $collection[$found];

                return $token->getLineNumber();
            }
        }

        return false;
    }
538251
public static function findByPasswordResetToken(string $token) : ?self
    {
        if (!static::isPasswordResetTokenValid($token)) {
            return null;
        }
        return static::findOne([
            'password_reset_token' => $token,
            'status' => self::STATUS_ACTIVE,
        ]);
    }
408796
public function update_type($id, $type, $desc) {
		$sql = "UPDATE cswal_token_type_table SET token_type=:type, 
			token_desc=:desc WHERE token_type_id=:id";
		$params = array(
			'id'	=> $id,
			'type'	=> $type,
			'desc'	=> $desc,
		);
		
		try {
			$retval = $this->db->run_update($sql, $params);
		} catch (Exception $ex) {
			throw new Exception(__METHOD__ .": failed to update type::: ". $ex->getMessage());
		}
		
		return $retval;
	}
1004166
public function isType($tokenTypes)
    {
        if (is_array($tokenTypes)) {
            return in_array($this->getType(), $tokenTypes);
        }

        return $this->getType() === $tokenTypes;
    }
108589
public function peekPrvsValidToken($startPos = null) {
		if ($startPos === null) {
			// default position for the search
			$pos = $this->getCurrentPosition() - 1;
		} else {
			// if defined, set the start position
			$pos = $startPos;
		}

		$token = null;
		while ($pos > 0) {

			$token = $this->tokens[$pos];
			$pos --;

			if (isset($this->ignoreTokens[$token->id])) {
				continue;
			} else if ($token->id === T_NEW_LINE) {
				continue;
			} else {
				break;
			}
		}

		return $token;
	}