Code Duplication    Length = 37-37 lines in 2 locations

src/PhpSpreadsheet/Reader/Xls/Escher.php 2 locations

@@ 314-350 (lines=37) @@
311
    /**
312
     * Read BlipJPEG record. Holds raw JPEG image data.
313
     */
314
    private function readBlipJPEG()
315
    {
316
        // offset: 0; size: 2; recVer and recInstance
317
318
        // bit: 4-15; mask: 0xFFF0; recInstance
319
        $recInstance = (0xFFF0 & Xls::getUInt2d($this->data, $this->pos)) >> 4;
320
321
        $length = Xls::getInt4d($this->data, $this->pos + 4);
322
        $recordData = substr($this->data, $this->pos + 8, $length);
323
324
        // move stream pointer to next record
325
        $this->pos += 8 + $length;
326
327
        $pos = 0;
328
329
        // offset: 0; size: 16; rgbUid1 (MD4 digest of)
330
        $rgbUid1 = substr($recordData, 0, 16);
331
        $pos += 16;
332
333
        // offset: 16; size: 16; rgbUid2 (MD4 digest), only if $recInstance = 0x46B or 0x6E3
334
        if (in_array($recInstance, [0x046B, 0x06E3])) {
335
            $rgbUid2 = substr($recordData, 16, 16);
336
            $pos += 16;
337
        }
338
339
        // offset: var; size: 1; tag
340
        $tag = ord($recordData[$pos]);
341
        $pos += 1;
342
343
        // offset: var; size: var; the raw image data
344
        $data = substr($recordData, $pos);
345
346
        $blip = new Blip();
347
        $blip->setData($data);
348
349
        $this->object->setBlip($blip);
350
    }
351
352
    /**
353
     * Read BlipPNG record. Holds raw PNG image data.
@@ 355-391 (lines=37) @@
352
    /**
353
     * Read BlipPNG record. Holds raw PNG image data.
354
     */
355
    private function readBlipPNG()
356
    {
357
        // offset: 0; size: 2; recVer and recInstance
358
359
        // bit: 4-15; mask: 0xFFF0; recInstance
360
        $recInstance = (0xFFF0 & Xls::getUInt2d($this->data, $this->pos)) >> 4;
361
362
        $length = Xls::getInt4d($this->data, $this->pos + 4);
363
        $recordData = substr($this->data, $this->pos + 8, $length);
364
365
        // move stream pointer to next record
366
        $this->pos += 8 + $length;
367
368
        $pos = 0;
369
370
        // offset: 0; size: 16; rgbUid1 (MD4 digest of)
371
        $rgbUid1 = substr($recordData, 0, 16);
372
        $pos += 16;
373
374
        // offset: 16; size: 16; rgbUid2 (MD4 digest), only if $recInstance = 0x46B or 0x6E3
375
        if ($recInstance == 0x06E1) {
376
            $rgbUid2 = substr($recordData, 16, 16);
377
            $pos += 16;
378
        }
379
380
        // offset: var; size: 1; tag
381
        $tag = ord($recordData[$pos]);
382
        $pos += 1;
383
384
        // offset: var; size: var; the raw image data
385
        $data = substr($recordData, $pos);
386
387
        $blip = new Blip();
388
        $blip->setData($data);
389
390
        $this->object->setBlip($blip);
391
    }
392
393
    /**
394
     * Read OPT record. This record may occur within DggContainer record or SpContainer.