Code Duplication    Length = 13-19 lines in 7 locations

src/PhpSpreadsheet/Reader/Xls.php 7 locations

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