Code Duplication    Length = 5-5 lines in 2 locations

src/PhpSpreadsheet/Writer/Ods.php 1 location

@@ 153-157 (lines=5) @@
150
            unlink($pFilename);
151
        }
152
        // Try opening the ZIP file
153
        if ($zip->open($pFilename, ZipArchive::OVERWRITE) !== true) {
154
            if ($zip->open($pFilename, ZipArchive::CREATE) !== true) {
155
                throw new \PhpOffice\PhpSpreadsheet\Writer\Exception("Could not open $pFilename for writing.");
156
            }
157
        }
158
159
        return $zip;
160
    }

src/PhpSpreadsheet/Writer/Xlsx.php 1 location

@@ 218-222 (lines=5) @@
215
                unlink($pFilename);
216
            }
217
            // Try opening the ZIP file
218
            if ($zip->open($pFilename, ZipArchive::OVERWRITE) !== true) {
219
                if ($zip->open($pFilename, ZipArchive::CREATE) !== true) {
220
                    throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('Could not open ' . $pFilename . ' for writing.');
221
                }
222
            }
223
224
            // Add [Content_Types].xml to ZIP file
225
            $zip->addFromString('[Content_Types].xml', $this->getWriterPart('ContentTypes')->writeContentTypes($this->spreadSheet, $this->includeCharts));