Skip to content

Commit

Permalink
Update LengthCalculator.php
Browse files Browse the repository at this point in the history
  • Loading branch information
Spomky authored Oct 21, 2021
1 parent 08594e6 commit dfce237
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/LengthCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ public static function getLengthOfArray(array $data): array
private static function computeLength(int $length): array
{
switch (true) {
case $length < 24:
case $length <= 23:
return [$length, null];
case $length < 0xFF:
case $length <= 0xFF:
return [24, chr($length)];
case $length < 0xFFFF:
return [25, self::hex2bin(dechex($length))];
case $length < 0xFFFFFFFF:
return [26, self::hex2bin(dechex($length))];
case BigInteger::of($length)->isLessThan(BigInteger::fromBase('FFFFFFFFFFFFFFFF', 16)):
return [27, self::hex2bin(dechex($length))];
case $length <= 0xFFFF:
return [25, self::hex2bin(static::fixHexLength(Utils::intToHex($length)))];
case $length <= 0xFFFFFFFF:
return [26, self::hex2bin(static::fixHexLength(Utils::intToHex($length)))];
case BigInteger::of($length)->isLessThanOrEqualTo(BigInteger::fromBase('FFFFFFFFFFFFFFFF', 16)):
return [27, self::hex2bin(static::fixHexLength(Utils::intToHex($length)))];
default:
return [31, null];
}
Expand Down

0 comments on commit dfce237

Please sign in to comment.