class ZipManager implements Countable (View source)

Multiple Comodojo\Zip\Zip manager

Methods

int
count()

Count the number of Zip objects registered to the manager

string
addZip(ZipInterface $zip)

Add a Zip object to manager and return its id

bool
removeZip(ZipInterface $zip)

Remove a Zip object from manager

bool
removeZipById(string $id)

Remove a Zip object from manager by Zip id

array
listZips()

Get a list of all registered Zips filenames as an array

getZip(string $id)

Get a Zip object by Id

setPath(string $path)

Set current base path (to add relative files to zip archive) for all Zips

array
getPath()

Get a list of paths used by Zips

setMask(int $mask)

Set default file mask for all Zips

array
getMask()

Get a list of masks from Zips

array
listFiles()

Get a list of files in Zips

bool
extract(string $destination, bool $separate = true, mixed $files = null)

Extract Zips to common destination

bool
merge(string $output_zip_file, bool $separate = true)

Merge multiple Zips into one

add(mixed $file_name_or_array, bool $flatten_root_folder = false)

Add a file to all registered Zips

delete(mixed $file_name_or_array)

Delete a file from any registered Zip

bool
close()

Close all Zips

Details

int count()

Count the number of Zip objects registered to the manager

Return Value

int

string addZip(ZipInterface $zip)

Add a Zip object to manager and return its id

Parameters

ZipInterface $zip

Return Value

string

bool removeZip(ZipInterface $zip)

Remove a Zip object from manager

Parameters

ZipInterface $zip

Return Value

bool

Exceptions

ZipException

bool removeZipById(string $id)

Remove a Zip object from manager by Zip id

Parameters

string $id

Return Value

bool

Exceptions

ZipException

array listZips()

Get a list of all registered Zips filenames as an array

Return Value

array

ZipInterface getZip(string $id)

Get a Zip object by Id

Parameters

string $id The zip id

Return Value

ZipInterface

Exceptions

ZipException

ZipManager setPath(string $path)

Set current base path (to add relative files to zip archive) for all Zips

Parameters

string $path

Return Value

ZipManager

Exceptions

ZipException

array getPath()

Get a list of paths used by Zips

Return Value

array

ZipManager setMask(int $mask)

Set default file mask for all Zips

Parameters

int $mask

Return Value

ZipManager

Exceptions

ZipException

array getMask()

Get a list of masks from Zips

Return Value

array

array listFiles()

Get a list of files in Zips

Return Value

array

Exceptions

ZipException

bool extract(string $destination, bool $separate = true, mixed $files = null)

Extract Zips to common destination

Parameters

string $destination Destination path
bool $separate (optional) If true (default), files will be placed in different directories
mixed $files (optional) a filename or an array of filenames

Return Value

bool

Exceptions

ZipException

bool merge(string $output_zip_file, bool $separate = true)

Merge multiple Zips into one

Parameters

string $output_zip_file Destination zip
bool $separate (optional) If true (default), files will be placed in different directories

Return Value

bool

Exceptions

ZipException

ZipManager add(mixed $file_name_or_array, bool $flatten_root_folder = false)

Add a file to all registered Zips

Parameters

mixed $file_name_or_array The filename to add or an array of filenames
bool $flatten_root_folder (optional) If true, the Zip root folder will be flattened (default: false)

Return Value

ZipManager

Exceptions

ZipException

ZipManager delete(mixed $file_name_or_array)

Delete a file from any registered Zip

Parameters

mixed $file_name_or_array The filename to add or an array of filenames

Return Value

ZipManager

Exceptions

ZipException

bool close()

Close all Zips

Return Value

bool

Exceptions

ZipException