diff --git a/src/PhpWord/Shared/ZipArchive.php b/src/PhpWord/Shared/ZipArchive.php index 52bf0bce..ced2fe09 100644 --- a/src/PhpWord/Shared/ZipArchive.php +++ b/src/PhpWord/Shared/ZipArchive.php @@ -89,8 +89,6 @@ class ZipArchive define('PCLZIP_TEMPORARY_DIR', sys_get_temp_dir() . '/'); } require_once 'PCLZip/pclzip.lib.php'; - } else { - $this->zip = new \ZipArchive(); } } @@ -120,6 +118,31 @@ class ZipArchive return $result; } + /** + * Open a new zip archive + * + * @param string $filename The file name of the ZIP archive to open + * @param int $flags The mode to use to open the archive + * @return bool + */ + public function open($filename, $flags = null) + { + $result = true; + $this->filename = $filename; + + if (!$this->usePclzip) { + $this->zip = new \ZipArchive(); + $result = $this->zip->open($this->filename, $flags); + $this->numFiles = $this->zip->numFiles; + } else { + $this->zip = new \PclZip($this->filename); + $this->tempDir = sys_get_temp_dir(); + $this->numFiles = count($this->zip->listContent()); + } + + return $result; + } + /** * Close the active archive * @@ -158,30 +181,6 @@ class ZipArchive } } - /** - * Open a new zip archive - * - * @param string $filename The file name of the ZIP archive to open - * @param int $flags The mode to use to open the archive - * @return bool - */ - public function open($filename, $flags = null) - { - $result = true; - $this->filename = $filename; - - if (!$this->usePclzip) { - $result = $this->zip->open($this->filename, $flags); - $this->numFiles = $this->zip->numFiles; - } else { - $this->tempDir = sys_get_temp_dir(); - $this->zip = new \PclZip($this->filename); - $this->numFiles = count($this->zip->listContent()); - } - - return $result; - } - /** * Extract file from archive by given file name (emulate \ZipArchive) *