Skip to content

Commit 5fe86ce

Browse files
simplified unpacking boolean and added null
1 parent da737a2 commit 5fe86ce

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

Unpacker.php

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,17 @@ private function u()
7777
if ($result) {
7878
return $output;
7979
}
80-
$output = $this->unpackBoolean($marker, $result);
81-
if ($result) {
82-
return $output;
80+
81+
if ($marker == 0xC3) {
82+
return true;
8383
}
84+
if ($marker == 0xC2) {
85+
return false;
86+
}
87+
if ($marker == 0xC0) {
88+
return null;
89+
}
90+
8491
$output = $this->unpackFloat($marker, $result);
8592
if ($result) {
8693
return $output;
@@ -325,23 +332,6 @@ private function unpackMap(int $marker, bool &$result = false): array
325332

326333
return $output;
327334
}
328-
329-
/**
330-
* @param int $marker
331-
* @param bool $result
332-
* @return bool
333-
*/
334-
private function unpackBoolean(int $marker, bool &$result = false): bool
335-
{
336-
if ($marker == 0xC3) {
337-
$result = true;
338-
return true;
339-
} elseif ($marker == 0xC2) {
340-
$result = true;
341-
return false;
342-
}
343-
return false;
344-
}
345335

346336
/**
347337
* @param int $marker

0 commit comments

Comments
 (0)