Code Duplication    Length = 13-13 lines in 5 locations

src/BufferUnpacker.php 5 locations

@@ 260-272 (lines=13) @@
257
        return $hi << 8 | $lo;
258
    }
259
260
    private function unpackUint32()
261
    {
262
        if (!isset($this->buffer[$this->offset + 3])) {
263
            throw new InsufficientDataException(4, \strlen($this->buffer) - $this->offset);
264
        }
265
266
        $num = \substr($this->buffer, $this->offset, 4);
267
        $this->offset += 4;
268
269
        $num = \unpack('N', $num);
270
271
        return $num[1];
272
    }
273
274
    private function unpackUint64()
275
    {
@@ 328-340 (lines=13) @@
325
        return $hi << 8 | $lo;
326
    }
327
328
    private function unpackInt32()
329
    {
330
        if (!isset($this->buffer[$this->offset + 3])) {
331
            throw new InsufficientDataException(4, \strlen($this->buffer) - $this->offset);
332
        }
333
334
        $num = \substr($this->buffer, $this->offset, 4);
335
        $this->offset += 4;
336
337
        $num = \unpack('i', \strrev($num));
338
339
        return $num[1];
340
    }
341
342
    private function unpackInt64()
343
    {
@@ 342-354 (lines=13) @@
339
        return $num[1];
340
    }
341
342
    private function unpackInt64()
343
    {
344
        if (!isset($this->buffer[$this->offset + 7])) {
345
            throw new InsufficientDataException(8, \strlen($this->buffer) - $this->offset);
346
        }
347
348
        $num = \substr($this->buffer, $this->offset, 8);
349
        $this->offset += 8;
350
351
        $set = \unpack('N2', $num);
352
353
        return $set[1] << 32 | $set[2];
354
    }
355
356
    private function unpackFloat32()
357
    {
@@ 356-368 (lines=13) @@
353
        return $set[1] << 32 | $set[2];
354
    }
355
356
    private function unpackFloat32()
357
    {
358
        if (!isset($this->buffer[$this->offset + 3])) {
359
            throw new InsufficientDataException(4, \strlen($this->buffer) - $this->offset);
360
        }
361
362
        $num = \substr($this->buffer, $this->offset, 4);
363
        $this->offset += 4;
364
365
        $num = \unpack('f', \strrev($num));
366
367
        return $num[1];
368
    }
369
370
    private function unpackFloat64()
371
    {
@@ 370-382 (lines=13) @@
367
        return $num[1];
368
    }
369
370
    private function unpackFloat64()
371
    {
372
        if (!isset($this->buffer[$this->offset + 7])) {
373
            throw new InsufficientDataException(8, \strlen($this->buffer) - $this->offset);
374
        }
375
376
        $num = \substr($this->buffer, $this->offset, 8);
377
        $this->offset += 8;
378
379
        $num = \unpack('d', \strrev($num));
380
381
        return $num[1];
382
    }
383
384
    private function unpackStr($length)
385
    {