Code Duplication    Length = 5-5 lines in 2 locations

src/PhpSpreadsheet/Writer/Ods.php 1 location

@@ 159-163 (lines=5) @@
156
            unlink($pFilename);
157
        }
158
        // Try opening the ZIP file
159
        if ($objZip->open($pFilename, $zipOverWrite) !== true) {
160
            if ($objZip->open($pFilename, $zipCreate) !== true) {
161
                throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("Could not open $pFilename for writing.");
162
            }
163
        }
164
165
        return $objZip;
166
    }

src/PhpSpreadsheet/Writer/Xlsx.php 1 location

@@ 226-230 (lines=5) @@
223
                unlink($pFilename);
224
            }
225
            // Try opening the ZIP file
226
            if ($objZip->open($pFilename, $zipOverWrite) !== true) {
227
                if ($objZip->open($pFilename, $zipCreate) !== true) {
228
                    throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('Could not open ' . $pFilename . ' for writing.');
229
                }
230
            }
231
232
            // Add [Content_Types].xml to ZIP file
233
            $objZip->addFromString('[Content_Types].xml', $this->getWriterPart('ContentTypes')->writeContentTypes($this->spreadSheet, $this->includeCharts));