Automattic\WooCommerce\Vendor\GraphQL\Language

Lexer::readCharsprivateWC 1.0

Reads next $numberOfChars UTF8 characters from the byte stream.

Method of the class: Lexer{}

No Hooks.

Returns

Array{String,. int}

Usage

// private - for code of main (parent) class only
$result = $this->readChars( $charCount ): array;
$charCount(int) (required)
.

Lexer::readChars() code WC 10.9.1

private function readChars(int $charCount): array
{
    $result = '';
    $totalBytes = 0;
    $byteOffset = $this->byteStreamPosition;

    for ($i = 0; $i < $charCount; ++$i) {
        [$char, $code, $bytes] = $this->readChar(false, $byteOffset);
        $totalBytes += $bytes;
        $byteOffset += $bytes;
        $result .= $char;
    }

    $this->moveStringCursor($charCount, $totalBytes);

    return [$result, $totalBytes];
}