Code Duplication    Length = 13-19 lines in 7 locations

src/PhpSpreadsheet/Reader/Xls.php 7 locations

@@ 3163-3175 (lines=13) @@
3160
    /**
3161
     * Read DEFAULTROWHEIGHT record.
3162
     */
3163
    private function readDefaultRowHeight()
3164
    {
3165
        $length = self::getUInt2d($this->data, $this->pos + 2);
3166
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3167
3168
        // move stream pointer to next record
3169
        $this->pos += 4 + $length;
3170
3171
        // offset: 0; size: 2; option flags
3172
        // offset: 2; size: 2; default height for unused rows, (twips 1/20 point)
3173
        $height = self::getUInt2d($recordData, 2);
3174
        $this->phpSheet->getDefaultRowDimension()->setRowHeight($height / 20);
3175
    }
3176
3177
    /**
3178
     * Read SHEETPR record.
@@ 3313-3327 (lines=15) @@
3310
    /**
3311
     * Read HCENTER record.
3312
     */
3313
    private function readHcenter()
3314
    {
3315
        $length = self::getUInt2d($this->data, $this->pos + 2);
3316
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3317
3318
        // move stream pointer to next record
3319
        $this->pos += 4 + $length;
3320
3321
        if (!$this->readDataOnly) {
3322
            // offset: 0; size: 2; 0 = print sheet left aligned, 1 = print sheet centered horizontally
3323
            $isHorizontalCentered = (bool) self::getUInt2d($recordData, 0);
3324
3325
            $this->phpSheet->getPageSetup()->setHorizontalCentered($isHorizontalCentered);
3326
        }
3327
    }
3328
3329
    /**
3330
     * Read VCENTER record.
@@ 3332-3346 (lines=15) @@
3329
    /**
3330
     * Read VCENTER record.
3331
     */
3332
    private function readVcenter()
3333
    {
3334
        $length = self::getUInt2d($this->data, $this->pos + 2);
3335
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3336
3337
        // move stream pointer to next record
3338
        $this->pos += 4 + $length;
3339
3340
        if (!$this->readDataOnly) {
3341
            // offset: 0; size: 2; 0 = print sheet aligned at top page border, 1 = print sheet vertically centered
3342
            $isVerticalCentered = (bool) self::getUInt2d($recordData, 0);
3343
3344
            $this->phpSheet->getPageSetup()->setVerticalCentered($isVerticalCentered);
3345
        }
3346
    }
3347
3348
    /**
3349
     * Read LEFTMARGIN record.
@@ 3482-3499 (lines=18) @@
3479
     * PROTECT - Sheet protection (BIFF2 through BIFF8)
3480
     *   if this record is omitted, then it also means no sheet protection.
3481
     */
3482
    private function readProtect()
3483
    {
3484
        $length = self::getUInt2d($this->data, $this->pos + 2);
3485
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3486
3487
        // move stream pointer to next record
3488
        $this->pos += 4 + $length;
3489
3490
        if ($this->readDataOnly) {
3491
            return;
3492
        }
3493
3494
        // offset: 0; size: 2;
3495
3496
        // bit 0, mask 0x01; 1 = sheet is protected
3497
        $bool = (0x01 & self::getUInt2d($recordData, 0)) >> 0;
3498
        $this->phpSheet->getProtection()->setSheet((bool) $bool);
3499
    }
3500
3501
    /**
3502
     * SCENPROTECT.
@@ 3504-3522 (lines=19) @@
3501
    /**
3502
     * SCENPROTECT.
3503
     */
3504
    private function readScenProtect()
3505
    {
3506
        $length = self::getUInt2d($this->data, $this->pos + 2);
3507
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3508
3509
        // move stream pointer to next record
3510
        $this->pos += 4 + $length;
3511
3512
        if ($this->readDataOnly) {
3513
            return;
3514
        }
3515
3516
        // offset: 0; size: 2;
3517
3518
        // bit: 0, mask 0x01; 1 = scenarios are protected
3519
        $bool = (0x01 & self::getUInt2d($recordData, 0)) >> 0;
3520
3521
        $this->phpSheet->getProtection()->setScenarios((bool) $bool);
3522
    }
3523
3524
    /**
3525
     * OBJECTPROTECT.
@@ 3527-3545 (lines=19) @@
3524
    /**
3525
     * OBJECTPROTECT.
3526
     */
3527
    private function readObjectProtect()
3528
    {
3529
        $length = self::getUInt2d($this->data, $this->pos + 2);
3530
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3531
3532
        // move stream pointer to next record
3533
        $this->pos += 4 + $length;
3534
3535
        if ($this->readDataOnly) {
3536
            return;
3537
        }
3538
3539
        // offset: 0; size: 2;
3540
3541
        // bit: 0, mask 0x01; 1 = objects are protected
3542
        $bool = (0x01 & self::getUInt2d($recordData, 0)) >> 0;
3543
3544
        $this->phpSheet->getProtection()->setObjects((bool) $bool);
3545
    }
3546
3547
    /**
3548
     * PASSWORD - Sheet protection (hashed) password (BIFF2 through BIFF8).
@@ 3568-3581 (lines=14) @@
3565
    /**
3566
     * Read DEFCOLWIDTH record.
3567
     */
3568
    private function readDefColWidth()
3569
    {
3570
        $length = self::getUInt2d($this->data, $this->pos + 2);
3571
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3572
3573
        // move stream pointer to next record
3574
        $this->pos += 4 + $length;
3575
3576
        // offset: 0; size: 2; default column width
3577
        $width = self::getUInt2d($recordData, 0);
3578
        if ($width != 8) {
3579
            $this->phpSheet->getDefaultColumnDimension()->setWidth($width);
3580
        }
3581
    }
3582
3583
    /**
3584
     * Read COLINFO record.