API
Interface

Elibyy\General\Adapter

interface Adapter

Interface Adapter the adapter interface for adapters to implement

Methods

__construct()

void open(string $file, int $flags)

opens the archive file or creates one by the file name supplied

File[] getFiles()

returns an array of {@link File} object to iterate on

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

return true if the unzipping was success else failure

object getArchive()

returns the archive object depends on the adapter

string getFilename()

returns the archive file name

int getFilesCount()

returns the number of files in the archive

string|bool getComment()

returns the archive comment if supported by the archive or false if not supported

Adapter|bool setComment(string $comment)

if supported by the adapter will set the new comment for the archive

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

adds a new folder recursively to the archive

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

adds a new file into the archive.

$this updateArchive()

updates the archive in the adapter to show latest changes

bool removeFileByObject(File $file)

removes a file from the archive using a {@link File} Object

bool removeFileByName(string $name)

removes a file from the archive using the file name in the archive

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

adds files using

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

static bool supports(string $type)

checks if the file type is supported by the adapter

Adapter compress(string $format)

Details

at line 25
public __construct()

at line 36
public void open(string $file, int $flags)

opens the archive file or creates one by the file name supplied

Parameters

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

Return Value

void

at line 44
public File[] getFiles()

returns an array of {@link File} object to iterate on

Return Value

File[] the array of the files in the archive

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

return true if the unzipping was success else failure

Parameters

string $destination
string|array $entries

Return Value

bool was it success ?

at line 63
public object getArchive()

returns the archive object depends on the adapter

Return Value

object the archive object instance depend on the adapter

at line 71
public string getFilename()

returns the archive file name

Return Value

string the archive file name

at line 79
public int getFilesCount()

returns the number of files in the archive

Return Value

int the number of files in the archive

at line 87
public string|bool getComment()

returns the archive comment if supported by the archive or false if not supported

Return Value

string|bool the comment of the archive

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

if supported by the adapter will set the new comment for the archive

Parameters

string $comment the new archive comment

Return Value

Adapter|bool the adapter instance on suceess else false

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

adds a new folder recursively to the archive

Parameters

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

Return Value

Adapter

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

adds a new file into the archive.

please note if $noUpdate is set to true you must run {@link Adapter#updateArchive()} manually,
or your archive info might not be updated

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 132
public $this updateArchive()

updates the archive in the adapter to show latest changes

Return Value

$this

at line 142
public bool removeFileByObject(File $file)

removes a file from the archive using a {@link File} Object

Parameters

File $file the File Object to remove

Return Value

bool was the file removed?

at line 152
public bool removeFileByName(string $name)

removes a file from the archive using the file name in the archive

Parameters

string $name the file name

Return Value

bool was the file removed?

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

adds files using

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 184
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 194
static public bool supports(string $type)

checks if the file type is supported by the adapter

Parameters

string $type the file type

Return Value

bool is the type supported

at line 202
public Adapter compress(string $format)

Parameters

string $format the format of the compression

Return Value

Adapter the resulting adapter