Exemple #1
0
 /**
  * Create a new zip archive
  *
  * @param   string  $zip_file   ZIP file name
  * @param   bool    $overwrite  overwrite existing file (if any)
  *
  * @return  \Comodojo\Zip\Zip
  * @throws  \Comodojo\Exception\ZipException
  */
 public static function create($zip_file, $overwrite = false)
 {
     $overwrite = filter_var($overwrite, FILTER_VALIDATE_BOOLEAN, array("options" => array("default" => false)));
     try {
         $zip = new Zip($zip_file);
         if ($overwrite) {
             $zip->setArchive(self::openZipFile($zip_file, ZipArchive::CREATE | ZipArchive::OVERWRITE));
         } else {
             $zip->setArchive(self::openZipFile($zip_file, ZipArchive::CREATE));
         }
     } catch (ZipException $ze) {
         throw $ze;
     }
     return $zip;
 }