Code Duplication    Length = 5-5 lines in 2 locations

src/PhpSpreadsheet/Writer/Ods.php 1 location

@@ 140-144 (lines=5) @@
137
            unlink($pFilename);
138
        }
139
        // Try opening the ZIP file
140
        if ($zip->open($pFilename, ZipArchive::OVERWRITE) !== true) {
141
            if ($zip->open($pFilename, ZipArchive::CREATE) !== true) {
142
                throw new WriterException("Could not open $pFilename for writing.");
143
            }
144
        }
145
146
        return $zip;
147
    }

src/PhpSpreadsheet/Writer/Xlsx.php 1 location

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