private function compactIntegerBuffer(ByteBuffer $buffer)
    {
        $length = $buffer->getLength();
        $raw = $buffer->getBinaryString();
        for ($i = 0; $i < ($length - 1); $i++) {
            if (ord($raw[$i]) !== 0) {
                break;
            }
        }
        if ($i !== 0) {
            return new ByteBuffer(\substr($raw, $i));
        }
        return $buffer;
    }
private function compactIntegerBuffer(ByteBuffer $buffer)
    {
        $length = $buffer->getLength();
        $raw = $buffer->getBinaryString();
        for ($i = 0; $i < ($length - 1); $i++) {
            if (ord($raw[$i]) !== 0) {
                break;
            }
        }
        if ($i !== 0) {
            return new ByteBuffer(\substr($raw, $i));
        }
        return $buffer;
    }
private function compactIntegerBuffer ( ByteBuffer $ buffer ) { $ length = $ buffer -> getLength ( ) ; $ raw = $ buffer -> getBinaryString ( ) ; for ( $ i = 0 ; $ i < ( $ length - 1 ) ; $ i ++ ) { if ( ord ( $ raw [ $ i ] ) !== 0 ) { break ; } } if ( $ i !== 0 ) { return new ByteBuffer ( \ substr ( $ raw , $ i ) ) ; } return $ buffer ; }
Removes all leading zero bytes from a ByteBuffer, but keeps one zero byte if it is the only byte left and the
original buffer did not have zero length.

@param ByteBuffer $buffer
@return ByteBuffer
Removes all leading zero bytes from a ByteBuffer but keeps one zero byte if it is the only byte left and the original buffer did not have zero length .