Code Duplication    Length = 14-20 lines in 3 locations

src/PhpSpreadsheet/Writer/Xls/Worksheet.php 3 locations

@@ 2139-2158 (lines=20) @@
2136
    /**
2137
     * Write SCENPROTECT.
2138
     */
2139
    private function writeScenProtect()
2140
    {
2141
        // Exit if sheet protection is not active
2142
        if (!$this->phpSheet->getProtection()->getSheet()) {
2143
            return;
2144
        }
2145
2146
        // Exit if scenarios are not protected
2147
        if (!$this->phpSheet->getProtection()->getScenarios()) {
2148
            return;
2149
        }
2150
2151
        $record = 0x00DD; // Record identifier
2152
        $length = 0x0002; // Bytes to follow
2153
2154
        $header = pack('vv', $record, $length);
2155
        $data = pack('v', 1);
2156
2157
        $this->append($header . $data);
2158
    }
2159
2160
    /**
2161
     * Write OBJECTPROTECT.
@@ 2163-2182 (lines=20) @@
2160
    /**
2161
     * Write OBJECTPROTECT.
2162
     */
2163
    private function writeObjectProtect()
2164
    {
2165
        // Exit if sheet protection is not active
2166
        if (!$this->phpSheet->getProtection()->getSheet()) {
2167
            return;
2168
        }
2169
2170
        // Exit if objects are not protected
2171
        if (!$this->phpSheet->getProtection()->getObjects()) {
2172
            return;
2173
        }
2174
2175
        $record = 0x0063; // Record identifier
2176
        $length = 0x0002; // Bytes to follow
2177
2178
        $header = pack('vv', $record, $length);
2179
        $data = pack('v', 1);
2180
2181
        $this->append($header . $data);
2182
    }
2183
2184
    /**
2185
     * Write the worksheet PASSWORD record.
@@ 2540-2553 (lines=14) @@
2537
     * Store the window zoom factor. This should be a reduced fraction but for
2538
     * simplicity we will store all fractions with a numerator of 100.
2539
     */
2540
    private function writeZoom()
2541
    {
2542
        // If scale is 100 we don't need to write a record
2543
        if ($this->phpSheet->getSheetView()->getZoomScale() == 100) {
2544
            return;
2545
        }
2546
2547
        $record = 0x00A0; // Record identifier
2548
        $length = 0x0004; // Bytes to follow
2549
2550
        $header = pack('vv', $record, $length);
2551
        $data = pack('vv', $this->phpSheet->getSheetView()->getZoomScale(), 100);
2552
        $this->append($header . $data);
2553
    }
2554
2555
    /**
2556
     * Get Escher object.