protected function getVlqBytesToInt()
    {
        $value = 0;
        $isBigInt = false;

        for ($this->pos; $this->pos < $this->maxLen; $this->pos++) {
            if (!$isBigInt) {
                $lshift = $value << 7;
                # An overflow bitshift will result in a negative number. This will check if GMP is available and flip it
                # to a bigint safe method in one shot.
                if ($lshift < 0) {
                    $isBigInt = true;
                    $this->throwIfBigIntGmpNeeded(true);
                    $value = \gmp_init($value);
                }
            }
            if ($isBigInt) {
                $lshift = \gmp_mul($value, \gmp_pow('2', 7));
            }
            $orVal = (\ord($this->binary[$this->pos]) & 0x7f);
            if ($isBigInt) {
                $value = \gmp_or($lshift, \gmp_init($orVal));
            } else {
                $value = $lshift | $orVal;
            }
            # We have reached the last byte if the MSB is not set.
            if ((\ord($this->binary[$this->pos]) & 0x80) === 0) {
                $this->pos++;
                return $isBigInt ? \gmp_strval($value) : $value;
            }
        }

        throw new EncoderException('Expected an ending byte to decode a VLQ, but none was found.');
    }