| @@ 229-241 (lines=13) @@ | ||
| 226 | return $hi << 8 | $lo; |
|
| 227 | } |
|
| 228 | ||
| 229 | private function unpackUint32() |
|
| 230 | { |
|
| 231 | if (!isset($this->buffer[$this->offset + 3])) { |
|
| 232 | throw InsufficientDataException::fromOffset($this->buffer, $this->offset, 4); |
|
| 233 | } |
|
| 234 | ||
| 235 | $num = \substr($this->buffer, $this->offset, 4); |
|
| 236 | $this->offset += 4; |
|
| 237 | ||
| 238 | $num = \unpack('N', $num); |
|
| 239 | ||
| 240 | return $num[1]; |
|
| 241 | } |
|
| 242 | ||
| 243 | private function unpackUint64() |
|
| 244 | { |
|
| @@ 297-309 (lines=13) @@ | ||
| 294 | return $hi << 8 | $lo; |
|
| 295 | } |
|
| 296 | ||
| 297 | private function unpackInt32() |
|
| 298 | { |
|
| 299 | if (!isset($this->buffer[$this->offset + 3])) { |
|
| 300 | throw InsufficientDataException::fromOffset($this->buffer, $this->offset, 4); |
|
| 301 | } |
|
| 302 | ||
| 303 | $num = \substr($this->buffer, $this->offset, 4); |
|
| 304 | $this->offset += 4; |
|
| 305 | ||
| 306 | $num = \unpack('i', \strrev($num)); |
|
| 307 | ||
| 308 | return $num[1]; |
|
| 309 | } |
|
| 310 | ||
| 311 | private function unpackInt64() |
|
| 312 | { |
|
| @@ 311-323 (lines=13) @@ | ||
| 308 | return $num[1]; |
|
| 309 | } |
|
| 310 | ||
| 311 | private function unpackInt64() |
|
| 312 | { |
|
| 313 | if (!isset($this->buffer[$this->offset + 7])) { |
|
| 314 | throw InsufficientDataException::fromOffset($this->buffer, $this->offset, 8); |
|
| 315 | } |
|
| 316 | ||
| 317 | $num = \substr($this->buffer, $this->offset, 8); |
|
| 318 | $this->offset += 8; |
|
| 319 | ||
| 320 | $set = \unpack('N2', $num); |
|
| 321 | ||
| 322 | return $set[1] << 32 | $set[2]; |
|
| 323 | } |
|
| 324 | ||
| 325 | private function unpackFloat32() |
|
| 326 | { |
|
| @@ 325-337 (lines=13) @@ | ||
| 322 | return $set[1] << 32 | $set[2]; |
|
| 323 | } |
|
| 324 | ||
| 325 | private function unpackFloat32() |
|
| 326 | { |
|
| 327 | if (!isset($this->buffer[$this->offset + 3])) { |
|
| 328 | throw InsufficientDataException::fromOffset($this->buffer, $this->offset, 4); |
|
| 329 | } |
|
| 330 | ||
| 331 | $num = \substr($this->buffer, $this->offset, 4); |
|
| 332 | $this->offset += 4; |
|
| 333 | ||
| 334 | $num = \unpack('f', \strrev($num)); |
|
| 335 | ||
| 336 | return $num[1]; |
|
| 337 | } |
|
| 338 | ||
| 339 | private function unpackFloat64() |
|
| 340 | { |
|
| @@ 339-351 (lines=13) @@ | ||
| 336 | return $num[1]; |
|
| 337 | } |
|
| 338 | ||
| 339 | private function unpackFloat64() |
|
| 340 | { |
|
| 341 | if (!isset($this->buffer[$this->offset + 7])) { |
|
| 342 | throw InsufficientDataException::fromOffset($this->buffer, $this->offset, 8); |
|
| 343 | } |
|
| 344 | ||
| 345 | $num = \substr($this->buffer, $this->offset, 8); |
|
| 346 | $this->offset += 8; |
|
| 347 | ||
| 348 | $num = \unpack('d', \strrev($num)); |
|
| 349 | ||
| 350 | return $num[1]; |
|
| 351 | } |
|
| 352 | ||
| 353 | private function unpackStr($length) |
|
| 354 | { |
|