| @@ 507-530 (lines=24) @@ | ||
| 504 | return $array; |
|
| 505 | } |
|
| 506 | ||
| 507 | public function unpackArrayHeader() |
|
| 508 | { |
|
| 509 | $buffer = &$this->buffer; |
|
| 510 | $offset = &$this->offset; |
|
| 511 | ||
| 512 | if (!isset($buffer[$offset])) { |
|
| 513 | throw new InsufficientDataException(); |
|
| 514 | } |
|
| 515 | ||
| 516 | $c = \ord($buffer[$offset]); |
|
| 517 | ++$offset; |
|
| 518 | ||
| 519 | if ($c >= 0x90 && $c <= 0x9f) { |
|
| 520 | return $c & 0xf; |
|
| 521 | } |
|
| 522 | if (0xdc === $c) { |
|
| 523 | return self::unpackUint16($buffer, $offset); |
|
| 524 | } |
|
| 525 | if (0xdd === $c) { |
|
| 526 | return self::unpackUint32($buffer, $offset); |
|
| 527 | } |
|
| 528 | ||
| 529 | throw UnpackingFailedException::unexpectedCode($c, 'array'); |
|
| 530 | } |
|
| 531 | ||
| 532 | public function unpackMap() |
|
| 533 | { |
|
| @@ 545-568 (lines=24) @@ | ||
| 542 | return $map; |
|
| 543 | } |
|
| 544 | ||
| 545 | public function unpackMapHeader() |
|
| 546 | { |
|
| 547 | $buffer = &$this->buffer; |
|
| 548 | $offset = &$this->offset; |
|
| 549 | ||
| 550 | if (!isset($buffer[$offset])) { |
|
| 551 | throw new InsufficientDataException(); |
|
| 552 | } |
|
| 553 | ||
| 554 | $c = \ord($buffer[$offset]); |
|
| 555 | ++$offset; |
|
| 556 | ||
| 557 | if ($c >= 0x80 && $c <= 0x8f) { |
|
| 558 | return $c & 0xf; |
|
| 559 | } |
|
| 560 | if (0xde === $c) { |
|
| 561 | return self::unpackUint16($buffer, $offset); |
|
| 562 | } |
|
| 563 | if (0xdf === $c) { |
|
| 564 | return self::unpackUint32($buffer, $offset); |
|
| 565 | } |
|
| 566 | ||
| 567 | throw UnpackingFailedException::unexpectedCode($c, 'map'); |
|
| 568 | } |
|
| 569 | ||
| 570 | public function unpackExt() |
|
| 571 | { |
|