API
Class

Elibyy\Reader

class Reader

Class Elibyy\Reader
this class is abstract layer for the adapters for files

Methods

__construct(string $file)

initiate a new instance of the reader with the file specified

Adapter getAdapter()

returns the current adapter instance provided by {@link Reader#_getAdapter(string $file)}

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

string getFilename()

this function returns the loaded archive name from the adapter

mixed getArchive()

returns the archive object from the adapter

File[] getFiles()

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

int getFilesCount()

returns the number of files in the archive

string getComment()

returns the archive comment from the adapter

Adapter setComment(string $comment)

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

adds a new folder to the archive recursively

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

adds a new file into the archive

Adapter updateArchive()

refreshes the archive in the adapter

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

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

adds files using

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

Adapter compress(string $format)

creates a new archive from the current archive with the new format specified

Details

at line 43
public __construct(string $file)

initiate a new instance of the reader with the file specified

Parameters

string $file the file to load with the reader

Exceptions

RuntimeException if no adapter found

at line 113
public Adapter getAdapter()

returns the current adapter instance provided by {@link Reader#_getAdapter(string $file)}

Return Value

Adapter the current adapter instance

at line 127
public mixed unzip(string $destination = null, string|array $entries = null)

Parameters

string $destination the destination folder to unzip to
string|array $entries the specific entries to extract from the archive can be either
a specific file (string) or an array for files

Return Value

mixed

at line 138
public string getFilename()

this function returns the loaded archive name from the adapter

Return Value

string the archive filename

at line 149
public mixed getArchive()

returns the archive object from the adapter

Return Value

mixed the archive received from the adapter

at line 160
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 171
public int getFilesCount()

returns the number of files in the archive

Return Value

int the total files in the archive

at line 182
public string getComment()

returns the archive comment from the adapter

Return Value

string the archive comment

at line 193
public Adapter setComment(string $comment)

Parameters

string $comment the new comment to set to the archive

Return Value

Adapter

at line 207
public Adapter addFolder(string $path, string $parent = null)

adds a new folder to the archive recursively

Parameters

string $path the full path of the directory in the file system
string $parent the relative path of the parent in the archive

Return Value

Adapter the adapter instance

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

adds a new file into the archive

Parameters

string $path the full path of the file in the file system
string $localName the local name of the file in the archive
int $start the start point to read from the file
int $length the end point to read from the file

Return Value

bool was the file added?

at line 234
public Adapter updateArchive()

refreshes the archive in the adapter

Return Value

Adapter the adapter with updated archive

at line 247
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 260
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 284
public bool 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

bool was glob added?

at line 298
public bool 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

bool was pattern added?

at line 311
public Adapter compress(string $format)

creates a new archive from the current archive with the new format specified

Parameters

string $format the format of the compression

Return Value

Adapter the resulting adapter