public function readVarint($isCollectionElement = false) { if ($isCollectionElement) { $length = $this->readShort(); } else { $length = strlen($this->data); } $hex = unpack('H*', $this->read($length)); return $this->bchexdec($hex[1]); }