Automattic\WooCommerce\Vendor\GraphQL\Language

Lexer::readDigitsprivateWC 1.0

Returns string with all digits + changes current string cursor position to point to the first char after digits.

Method of the class: Lexer{}

No Hooks.

Returns

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->readDigits(): string;

Lexer::readDigits() code WC 10.9.1

private function readDigits(): string
{
    [$char, $code] = $this->readChar();

    if ($code >= 48 && $code <= 57) { // 0 - 9
        $value = '';

        do {
            $value .= $char;
            [$char, $code] = $this->moveStringCursor(1, 1)->readChar();
        } while ($code >= 48 && $code <= 57); // 0 - 9

        return $value;
    }

    if ($this->position > $this->source->length - 1) {
        $code = null;
    }

    throw new SyntaxError($this->source, $this->position, 'Invalid number, expected digit but got: ' . Utils::printCharCode($code));
}