/**
  * @return int
  * @throws BinaryDataReaderException
  */
 private function readVariableInt()
 {
     $length = $this->binaryDataReader->getBinaryDataLength();
     $len = 0;
     for ($i = 0; $i < $length; $i++) {
         $size = $this->binaryDataReader->readUInt8();
         // Get the next 7 bits of the length.
         $len |= ($size & 127) << 7 * $i;
         if (($size & 128) === 0) {
             // This was the last byte. Return successfully.
             return $len;
         }
     }
     return $len;
 }