| @@ 111-122 (lines=12) @@ | ||
| 108 | return $this; |
|
| 109 | } |
|
| 110 | ||
| 111 | public function skip(int $length) : self |
|
| 112 | { |
|
| 113 | $offset = $this->offset + $length; |
|
| 114 | ||
| 115 | if (!isset($this->buffer[$offset])) { |
|
| 116 | throw new InsufficientDataException("Unable to seek to position $offset"); |
|
| 117 | } |
|
| 118 | ||
| 119 | $this->offset = $offset; |
|
| 120 | ||
| 121 | return $this; |
|
| 122 | } |
|
| 123 | ||
| 124 | public function getRemainingCount() : int |
|
| 125 | { |
|
| @@ 152-162 (lines=11) @@ | ||
| 149 | * |
|
| 150 | * @return string |
|
| 151 | */ |
|
| 152 | public function read($length) |
|
| 153 | { |
|
| 154 | if (!isset($this->buffer[$this->offset + $length - 1])) { |
|
| 155 | throw new InsufficientDataException(); |
|
| 156 | } |
|
| 157 | ||
| 158 | $data = \substr($this->buffer, $this->offset, $length); |
|
| 159 | $this->offset += $length; |
|
| 160 | ||
| 161 | return $data; |
|
| 162 | } |
|
| 163 | ||
| 164 | public function tryUnpack() : array |
|
| 165 | { |
|
| @@ 571-581 (lines=11) @@ | ||
| 568 | return \sprintf('%u', $num); |
|
| 569 | } |
|
| 570 | ||
| 571 | private function unpackInt8() |
|
| 572 | { |
|
| 573 | if (!isset($this->buffer[$this->offset])) { |
|
| 574 | throw new InsufficientDataException(); |
|
| 575 | } |
|
| 576 | ||
| 577 | $num = \ord($this->buffer[$this->offset]); |
|
| 578 | ++$this->offset; |
|
| 579 | ||
| 580 | return $num > 0x7f ? $num - 0x100 : $num; |
|
| 581 | } |
|
| 582 | ||
| 583 | private function unpackInt16() |
|
| 584 | { |
|