Skip to content

Commit

Permalink
deps: allow brick/math 0.12
Browse files Browse the repository at this point in the history
deps: other dev deps update
  • Loading branch information
Spomky committed Jan 29, 2024
1 parent 87f4f20 commit 95ebb65
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/Decoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private function process(Stream $stream, bool $breakable): CBORObject
case CBORObject::FUTURE_USE_3: //30
throw new InvalidArgumentException(sprintf(
'Cannot parse the data. Found invalid Additional Information "%s" (%d).',
str_pad(decbin($ai), 8, '0', STR_PAD_LEFT),
mb_str_pad(decbin($ai), 8, '0', STR_PAD_LEFT),
$ai
));
case CBORObject::LENGTH_INDEFINITE: //31
Expand Down Expand Up @@ -129,7 +129,7 @@ private function processFinite(Stream $stream, int $mt, int $ai, ?string $val):
default:
throw new RuntimeException(sprintf(
'Unsupported major type "%s" (%d).',
str_pad(decbin($mt), 5, '0', STR_PAD_LEFT),
mb_str_pad(decbin($mt), 5, '0', STR_PAD_LEFT),
$mt
)); // Should never append
}
Expand Down Expand Up @@ -190,7 +190,7 @@ private function processInfinite(Stream $stream, int $mt, bool $breakable): CBOR
default :
throw new InvalidArgumentException(sprintf(
'Cannot parse the data. Found infinite length for Major Type "%s" (%d).',
str_pad(decbin($mt), 5, '0', STR_PAD_LEFT),
mb_str_pad(decbin($mt), 5, '0', STR_PAD_LEFT),
$mt
));
}
Expand Down
2 changes: 1 addition & 1 deletion src/LengthCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private static function computeLength(int $length): array

private static function hex2bin(string $data): string
{
$data = str_pad($data, (int) (2 ** ceil(log(mb_strlen($data, '8bit'), 2))), '0', STR_PAD_LEFT);
$data = mb_str_pad($data, (int) (2 ** ceil(log(mb_strlen($data, '8bit'), 2))), '0', STR_PAD_LEFT);
$result = hex2bin($data);
if ($result === false) {
throw new InvalidArgumentException('Unable to convert the data');
Expand Down
6 changes: 3 additions & 3 deletions src/NegativeIntegerObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ private static function createBigInteger(BigInteger $integer): self
break;
case $computed_value->isLessThan(BigInteger::fromBase('FF', 16)):
$ai = 24;
$data = self::hex2bin(str_pad($computed_value->toBase(16), 2, '0', STR_PAD_LEFT));
$data = self::hex2bin(mb_str_pad($computed_value->toBase(16), 2, '0', STR_PAD_LEFT));
break;
case $computed_value->isLessThan(BigInteger::fromBase('FFFF', 16)):
$ai = 25;
$data = self::hex2bin(str_pad($computed_value->toBase(16), 4, '0', STR_PAD_LEFT));
$data = self::hex2bin(mb_str_pad($computed_value->toBase(16), 4, '0', STR_PAD_LEFT));
break;
case $computed_value->isLessThan(BigInteger::fromBase('FFFFFFFF', 16)):
$ai = 26;
$data = self::hex2bin(str_pad($computed_value->toBase(16), 8, '0', STR_PAD_LEFT));
$data = self::hex2bin(mb_str_pad($computed_value->toBase(16), 8, '0', STR_PAD_LEFT));
break;
default:
throw new InvalidArgumentException(
Expand Down
2 changes: 1 addition & 1 deletion src/Tag/TimestampTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function normalize(): DateTimeInterface
if (mb_strlen($parts[1], '8bit') > 6) {
$parts[1] = mb_substr($parts[1], 0, 6, '8bit');
} else {
$parts[1] = str_pad($parts[1], 6, '0', STR_PAD_RIGHT);
$parts[1] = mb_str_pad($parts[1], 6, '0', STR_PAD_RIGHT);
}
}
$formatted = DateTimeImmutable::createFromFormat('U.u', implode('.', $parts));
Expand Down
6 changes: 3 additions & 3 deletions src/UnsignedIntegerObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ private static function createBigInteger(BigInteger $integer): self
break;
case $integer->isLessThan(BigInteger::fromBase('FF', 16)):
$ai = 24;
$data = self::hex2bin(str_pad($integer->toBase(16), 2, '0', STR_PAD_LEFT));
$data = self::hex2bin(mb_str_pad($integer->toBase(16), 2, '0', STR_PAD_LEFT));
break;
case $integer->isLessThan(BigInteger::fromBase('FFFF', 16)):
$ai = 25;
$data = self::hex2bin(str_pad($integer->toBase(16), 4, '0', STR_PAD_LEFT));
$data = self::hex2bin(mb_str_pad($integer->toBase(16), 4, '0', STR_PAD_LEFT));
break;
case $integer->isLessThan(BigInteger::fromBase('FFFFFFFF', 16)):
$ai = 26;
$data = self::hex2bin(str_pad($integer->toBase(16), 8, '0', STR_PAD_LEFT));
$data = self::hex2bin(mb_str_pad($integer->toBase(16), 8, '0', STR_PAD_LEFT));
break;
default:
throw new InvalidArgumentException(
Expand Down
2 changes: 1 addition & 1 deletion tests/OtherObject/AllTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,6 @@ public static function getDoublePrecisionFloatObject(): Iterator

private static function bitsToByteString(string $data, int $length): string
{
return str_pad(BigInteger::fromBase($data, 2)->toBytes(false), $length, "\0", STR_PAD_LEFT);
return mb_str_pad(BigInteger::fromBase($data, 2)->toBytes(false), $length, "\0", STR_PAD_LEFT);
}
}

0 comments on commit 95ebb65

Please sign in to comment.