API
Class

Elibyy\Adapters\ZipAdapter

class ZipAdapter implements Adapter

Class ZipAdapter this class is an adapter for zip files

Methods

__construct()

static bool supports(string $type)

File[] getFiles()

int getFilesCount()

object getArchive()

bool unzip(string $destination = null, string|array $entries = null)

string getFilename()

string|bool getComment()

Adapter|bool setComment(string $comment)

$this updateArchive()

void open(string $file, int $flags = \ZipArchive::CREATE)

Adapter addFolder(string $path, string $parent = '')

bool addFile(string $path, string $localName = null, int $start, null $length = null, bool $noUpdate = false)

bool removeFileByObject(File $file)

bool removeFileByName(string $name)

array addGlob(string $glob, int $flags = GLOB_BRACE, array $options = array())

array addPattern(string $pattern, string $directory, array $options = array())

Adapter compress(string $format)

Details

at line 48
public __construct()

at line 59
static public bool supports(string $type)

Parameters

string $type the file type

Return Value

bool is the type supported

at line 67
public File[] getFiles()

Return Value

File[] the array of the files in the archive

at line 82
public int getFilesCount()

Return Value

int the number of files in the archive

at line 90
public object getArchive()

Return Value

object the archive object instance depend on the adapter

at line 98
public bool unzip(string $destination = null, string|array $entries = null)

Parameters

string $destination
string|array $entries

Return Value

bool was it success ?

at line 110
public string getFilename()

Return Value

string the archive file name

at line 118
public string|bool getComment()

Return Value

string|bool the comment of the archive

at line 126
public Adapter|bool setComment(string $comment)

Parameters

string $comment the new archive comment

Return Value

Adapter|bool the adapter instance on suceess else false

at line 135
public $this updateArchive()

Return Value

$this

at line 144
public void open(string $file, int $flags = \ZipArchive::CREATE)

Parameters

string $file the Archive filename
int $flags the flags depend on the adapter

Return Value

void

at line 152
public Adapter addFolder(string $path, string $parent = '')

Parameters

string $path the folder full path
string $parent the parent path used for relative path in the archive

Return Value

Adapter

at line 180
public bool addFile(string $path, string $localName = null, int $start, null $length = null, bool $noUpdate = false)

Parameters

string $path the file full path
string $localName the file local name in the archive
int $start the start position to start from when reading the file
null $length the end position to stop when reading the file
bool $noUpdate if set will not update the archive after adding the file

Return Value

bool was the file added?

at line 194
public bool removeFileByObject(File $file)

Parameters

File $file the File Object to remove

Return Value

bool was the file removed?

at line 204
public bool removeFileByName(string $name)

Parameters

string $name the file name

Return Value

bool was the file removed?

at line 214
public array addGlob(string $glob, int $flags = GLOB_BRACE, array $options = array())

Parameters

string $glob the glob pattern
int $flags glob flags
array $options An associative array of options. Available options are:

"addpath"

Prefix to prepend when translating to the local path of the file within the archive. This is applied after any remove operations defined by the "removepath" or "removeallpath" options.

Return Value

array the result of the glob

at line 224
public array addPattern(string $pattern, string $directory, array $options = array())

Parameters

string $pattern the regular expression pattern
string $directory the path of the directory
array $options An associative array of options accepted by ZipArchive::addGlob.

Return Value

array the result of the pattern

at line 240
public Adapter compress(string $format)

Parameters

string $format the format of the compression

Return Value

Adapter the resulting adapter