src/Binary/SizeCalculator.php
public function computeVarintSize($value)
    {
        if (($value & (0xffffffff <<  7)) === 0) {
            return 1;
        }

        if (($value & (0xffffffff << 14)) === 0) {
            return 2;
        }

        if (($value & (0xffffffff << 21)) === 0) {
            return 3;
        }

        if (($value & (0xffffffff << 28)) === 0) {
            return 4;
        }

        if (($value & (0xffffffff << 35)) === 0) {
            return 5;
        }

        if (($value & (0xffffffff << 42)) === 0) {
            return 6;
        }

        if (($value & (0xffffffff << 49)) === 0) {
            return 7;
        }

        if (($value & (0xffffffff << 56)) === 0) {
            return 8;
        }

        if (($value & (0xffffffff << 63)) === 0) {
            return 9;
        }

        return 10;
    }
public function computeVarintSize($value)
    {
        if (($value & (0xffffffff <<  7)) === 0) {
            return 1;
        }

        if (($value & (0xffffffff << 14)) === 0) {
            return 2;
        }

        if (($value & (0xffffffff << 21)) === 0) {
            return 3;
        }

        if (($value & (0xffffffff << 28)) === 0) {
            return 4;
        }

        if (($value & (0xffffffff << 35)) === 0) {
            return 5;
        }

        if (($value & (0xffffffff << 42)) === 0) {
            return 6;
        }

        if (($value & (0xffffffff << 49)) === 0) {
            return 7;
        }

        if (($value & (0xffffffff << 56)) === 0) {
            return 8;
        }

        if (($value & (0xffffffff << 63)) === 0) {
            return 9;
        }

        return 10;
    }
public function computeVarintSize ( $ value ) { if ( ( $ value & ( 0xffffffff << 7 ) ) === 0 ) { return 1 ; } if ( ( $ value & ( 0xffffffff << 14 ) ) === 0 ) { return 2 ; } if ( ( $ value & ( 0xffffffff << 21 ) ) === 0 ) { return 3 ; } if ( ( $ value & ( 0xffffffff << 28 ) ) === 0 ) { return 4 ; } if ( ( $ value & ( 0xffffffff << 35 ) ) === 0 ) { return 5 ; } if ( ( $ value & ( 0xffffffff << 42 ) ) === 0 ) { return 6 ; } if ( ( $ value & ( 0xffffffff << 49 ) ) === 0 ) { return 7 ; } if ( ( $ value & ( 0xffffffff << 56 ) ) === 0 ) { return 8 ; } if ( ( $ value & ( 0xffffffff << 63 ) ) === 0 ) { return 9 ; } return 10 ; }
Compute the number of bytes that would be needed to encode a varint.

@param integer $value

@return integer
Compute the number of bytes that would be needed to encode a varint .