Implements the array access interface. Return the computed idf or
the logarithm of the count of the documents for a token we have not
seen before.

@param  string $token The token to return the idf for
@return float  The idf
179240
public function offsetGet($token)
    {
        if (isset($this->idf[$token])) {
            return $this->idf[$token];
        } else {
            return $this->logD;
        }
    }
749309
public function getFromToken($token)
    {
        $rest = $this->callService('GET', self::API_SHARE_LINK . $token);

        return $rest->getModel(models\FileSystem\ShareLink::class);
    }
92737
public function get($token)
    {
        $result = $this->getConnection()->table('oauth_access_tokens')
                ->where('oauth_access_tokens.id', $token)
                ->first();

        if (is_null($result)) {
            return;
        }

        return (new AccessTokenEntity($this->getServer()))
               ->setId($result->id)
               ->setExpireTime((int) $result->expire_time);
    }
848802
public function findUserByForgetPasswordToken($token)
    {
        try {
            $builder = $this->createQueryBuilder('u');

            return $builder->where($builder->expr()->eq('u.forgetPasswordToken', ':token'))
                ->andWhere($builder->expr()->isNotNull('u.forgetPasswordExpired'))
                ->andWhere('u.forgetPasswordExpired >= :today')
                ->setParameter('token', $token)
                ->setParameter('today', new \DateTime(), Type::DATETIME)
                ->getQuery()
                ->getSingleResult();

        } catch (NoResultException $ex) {
            // This means that nothing was found this thrown by the getSingleResult method
            return null;
        } catch (NonUniqueResultException $ex) {
            // this means that there was more then one result found and we have duplicate tokens in our database.
            // Look up the code for the error message in the logs
            throw new ProgrammerException('Duplicate Forget Password Token was found.', ProgrammerException::FORGET_PASSWORD_TOKEN_DUPLICATE_EXCEPTION_CODE);
        }
    }
1311649
public static function forgeDtoFromToken($token) {
        $token = trim($token);
        if(empty($token)) {
            return null;
        }
	    $token = trim($token);
	    $token = StringHelper::removeDoubleSpace($token);
        $tokenSegments = explode(SPC, $token);
	    $countSegments = count($tokenSegments);
       
        $isValid = $countSegments == 1 || $countSegments == 2;
        if(!$isValid) {
            throw new InvalidArgumentException('Invalid token format');
        }
		$tokenDto = new TokenDto();
        if(count($tokenSegments) == 1) {
	        $tokenDto->type = null;
	        $tokenDto->token = $tokenSegments[0];
        } elseif(count($tokenSegments) == 2) {
	        $tokenDto->type = strtolower($tokenSegments[0]);
	        $tokenDto->token = $tokenSegments[1];
        }
        return $tokenDto;
    }
859422
protected static function parseArgument( $token )
	{
		$description = null;

		if ( Str::contains( $token, ' : ' ) )
		{
			list( $token, $description ) = explode( ' : ', $token, 2 );

			$token = trim( $token );

			$description = trim( $description );
		}

		switch ( true )
		{
			case Str::endsWith( $token, '?*' ):
				return new InputArgument( trim( $token, '?*' ), InputArgument::IS_ARRAY, $description );
			case Str::endsWith( $token, '*' ):
				return new InputArgument( trim( $token, '*' ), InputArgument::IS_ARRAY | InputArgument::REQUIRED, $description );
			case Str::endsWith( $token, '?' ):
				return new InputArgument( trim( $token, '?' ), InputArgument::OPTIONAL, $description );
			case preg_match( '/(.+)\=(.+)/', $token, $matches ):
				return new InputArgument( $matches[1], InputArgument::OPTIONAL, $description, $matches[2] );
			default:
				return new InputArgument( $token, InputArgument::REQUIRED, $description );
		}
	}
438840
protected function getValueOfToken(array $token)
    {
        switch ($token[Lexer::TYPE]) {
            case Lexer::T_QUOTED_STRING:
                return substr($token[Lexer::VALUE], 1, -1);

            case Lexer::T_NUMBER:
                return (float)$token[Lexer::VALUE];

            case Lexer::T_TRUE:
                return true;

            case Lexer::T_FALSE:
                return false;

            case Lexer::T_NULL:
                return null;
        }

        return null;
    }
202622
private function _processComment($token) {
		// Count the lines of comment
		if ($token->id === T_COMMENT) {
			$this->_ncssTotalSingleComment ++;
			$this->_ncssFileSingleComment ++;
		} else if ($token->id === T_ML_COMMENT) {
			$this->_ncssTotalMultiComment ++;
			$this->_ncssFileMultiComment ++;
		} else if ($token->id === T_DOC_COMMENT) {
			$this->_ncssTotalPhpdoc ++;
			$this->_ncssFilePhpdoc ++;
			$this->_ncssTotalLinesPhpdoc ++;
			$this->_ncssFileLinesPhpdoc ++;
			if ($this->_isFileDocComment()) {
				$this->_processAnnotation(T_FILE, $token->text);
			}
		}

		// Count the @params, @returns and @throw
		if (stripos($token->text, '/**') !== false) {
			// Reset the count of elements if it's a new docblock
			$this->statementStack->getCurrentStackItem()->docblocNbParams = 0;
			$this->statementStack->getCurrentStackItem()->docblocNbReturns = 0;
			$this->statementStack->getCurrentStackItem()->docblocNbThrows = 0;
		}
		if (stripos($token->text, '@param') !== false) {
			$this->statementStack->getCurrentStackItem()->docblocNbParams ++;
		}
		if (stripos($token->text, '@return') !== false) {
			$this->statementStack->getCurrentStackItem()->docblocNbReturns ++;
		}
		if (stripos($token->text, '@throw') !== false) {
			$this->statementStack->getCurrentStackItem()->docblocNbThrows ++;
		}
		if (stripos($token->text, '@inheritdoc') !== false) {
			$this->statementStack->getCurrentStackItem()->docblocInheritDoc = true;
		}

		// Check if the comment starts with '#'
		if ($this->_isActive('noShellComments')) {
			$todoStr = strpos($token->text, '#');
			if ($todoStr === 0) {
				$this->_writeError('noShellComments', $this->_getMessage('NO_SHELL_COMMENTS'));
			}
		}

		// Check if the comment contains a TO DO
		$this->_processTODO($token);
	}
980511
public function getByActionToken(string $token)
	{
		return $this->setAuthorizer($this->getModel()->where('action_token', '=', $token)->first());
	}
251098
public function getPayload($token)
    {
        try {
            $jws = SimpleJWS::load($token);

            return $jws->getPayload();
        } catch (\InvalidArgumentException $ex) {
            throw new ProgrammerException('Unable to read jws token.', ProgrammerException::JWS_INVALID_TOKEN_FORMAT);
        }
    }
723031
public static function get_by_token($token) {
	$mysql = bootstrap::get_library('mysql');
	
	$sql   = "SELECT * FROM `login_tokens` WHERE `code` = '%s';";
	$login = $mysql::select('row', $sql, $token);
	if (empty($login)) {
		return false;
	}
	
	return new static($login['id']);
}
249346
public function parse(Token $token)
    {
        parent::parse($token);

        $split = preg_split(self::REGEX, $token->getValue(), 2, PREG_SPLIT_DELIM_CAPTURE + PREG_SPLIT_NO_EMPTY);
        $splitSize = count($split);
        if (1 === $splitSize) {
            return $this->functionTokenParser->parse($token);
        }

        if (3 !== count($split) && 4 !== count($split)) {
            throw ExpressionLanguageExceptionFactory::createForCouldNotLexValue($token->getValue());
        }

        $values = [
            $this->parser->parse($split[0].$split[1]),
        ];
        if (3 === $splitSize) {
            $values[] = $this->parser->parse('<'.$split[2]);
        }

        if (4 === $splitSize) {
            $values[] = $this->parser->parse($split[2]);
            $values[] = $this->parser->parse('<'.$split[3]);
        }

        return $this->mergeValues($values);
    }
225684
public function getByAccessToken(string $token)
	{
		return $this->setAuthorizer($this->getModel()->where('access_token', '=', $token)->first());
	}
778609
private function getLinksField($token)
    {
        $uri = $this->service->getInvoicePdfUri($token);
        $text = ucfirst($this->t('invoice'));
        $title = sprintf($this->t('open_as_pdf'), $text);
        /** @noinspection HtmlUnknownTarget */
        $invoiceLink = sprintf('<a class="%4$s" href="%1$s" title="%3$s">%2$s</a>', $uri, $text, $title, 'pdf');

        $uri = $this->service->getPackingSlipUri($token);
        $text = ucfirst($this->t('packing_slip'));
        $title = sprintf($this->t('open_as_pdf'), $text);
        /** @noinspection HtmlUnknownTarget */
        $packingSlipLink = sprintf('<a class="%4$s" href="%1$s" title="%3$s">%2$s</a>', $uri, $text, $title, 'pdf');

        $fields = array(
            'links' => array(
                'type' => 'markup',
                'label' => $this->t('documents'),
                'value' => "$invoiceLink $packingSlipLink",
            ),
        );
        return $fields;
    }
732776
private function parseArgument($token)
    {
        $c = \count($this->arguments);

        // if input is expecting another argument, add it
        if ($this->definition->hasArgument($c)) {
            $arg = $this->definition->getArgument($c);
            $this->arguments[$arg->getName()] = $arg->isArray() ? [$token] : $token;

        // if last argument isArray(), append token to last argument
        } elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) {
            $arg = $this->definition->getArgument($c - 1);
            $this->arguments[$arg->getName()][] = $token;

        // unexpected argument
        } else {
            $all = $this->definition->getArguments();
            if (\count($all)) {
                throw new RuntimeException(sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all))));
            }

            throw new RuntimeException(sprintf('No arguments expected, got "%s".', $token));
        }
    }
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;
    }
109274
public function getFromToken( $Token){
        $rest = $this->getService( self::API_SHARE_LINK . $Token);
        $rest->GET();

        return $rest->getResult( models\FileSystem\ShareLink::class);
    }