From 0d1a085f9e31185bc29feacd52ffed4a22cecd47 Mon Sep 17 00:00:00 2001 From: Don Hardman Date: Mon, 2 Aug 2021 16:27:13 +0700 Subject: [PATCH] Add shortcut readBool for reading uint as bool --- src/VarInt.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/VarInt.php b/src/VarInt.php index 1724988..fd86f69 100644 --- a/src/VarInt.php +++ b/src/VarInt.php @@ -23,6 +23,11 @@ public static function readUint(string $hex, int $offset = 0): array { return [0, 0]; } + public static function readBool(string $hex, int $offset = 0): array { + [$flag, $next_offset] = static::readUint($hex, $offset); + return [!!$flag, $next_offset]; + } + public static function packUint(int $value): string { $h = ''; $i = 0;