Zippy API
Interface

Alchemy\Zippy\Adapter\AdapterInterface

interface AdapterInterface

Methods

ArchiveInterface open(String $path)

Opens an archive

ArchiveInterface create(String $path, String|Array|Traversable|null $files = null, Boolean $recursive = true)

Creates a new archive

Boolean isSupported()

Tests if the adapter is supported by the current environment

Array listMembers(ResourceInterface $resource)

Returns the list of all archive members

Array add(ResourceInterface $resource, String|Array|Traversable $files, Boolean $recursive = true)

Adds a file to the archive

static String getName()

Returns the adapter name

Array remove(ResourceInterface $resource, String|Array|Traversable $files)

Removes a member of the archive

SplFileInfo extract(ResourceInterface $resource, String|null $to = null)

Extracts an entire archive

SplFileInfo extractMembers(ResourceInterface $resource, Array $members, String|null $to = null)

Extracts specific members of the archive

Details

at line 31
public ArchiveInterface open(String $path)

Opens an archive

Parameters

String $path The path to the archive

Return Value

ArchiveInterface

Exceptions

InvalidArgumentException In case the provided path is not valid
RuntimeException In case of failure

at line 49
public ArchiveInterface create(String $path, String|Array|Traversable|null $files = null, Boolean $recursive = true)

Creates a new archive

Please note some adapters can not create empty archives.
They would throw a `NotSupportedException` in case you ask to create an archive without files

Parameters

String $path The path to the archive
String|Array|Traversable|null $files A filename, an array of files, or a \Traversable instance
Boolean $recursive Whether to recurse or not in the provided directories

Return Value

ArchiveInterface

Exceptions

RuntimeException In case of failure
NotSupportedException In case the operation in not supported
InvalidArgumentException In case no files could be added

at line 56
public Boolean isSupported()

Tests if the adapter is supported by the current environment

Return Value

Boolean

at line 67
public Array listMembers(ResourceInterface $resource)

Returns the list of all archive members

Parameters

ResourceInterface $resource The path to the archive

Return Value

Array

Exceptions

RuntimeException In case of failure

at line 81
public Array add(ResourceInterface $resource, String|Array|Traversable $files, Boolean $recursive = true)

Adds a file to the archive

Parameters

ResourceInterface $resource The path to the archive
String|Array|Traversable $files An array of paths to add, relative to cwd
Boolean $recursive Whether or not to recurse in the provided directories

Return Value

Array

Exceptions

RuntimeException In case of failure
InvalidArgumentException In case no files could be added

at line 88
static public String getName()

Returns the adapter name

Return Value

String

at line 101
public Array remove(ResourceInterface $resource, String|Array|Traversable $files)

Removes a member of the archive

Parameters

ResourceInterface $resource The path to the archive
String|Array|Traversable $files A filename, an array of files, or a \Traversable instance

Return Value

Array

Exceptions

RuntimeException In case of failure
InvalidArgumentException In case no files could be removed

at line 116
public SplFileInfo extract(ResourceInterface $resource, String|null $to = null)

Extracts an entire archive

Note that any existing files will be overwritten by the adapter

Parameters

ResourceInterface $resource The path to the archive
String|null $to The path where to extract the archive

Return Value

SplFileInfo The extracted archive

Exceptions

RuntimeException In case of failure
InvalidArgumentException In case the provided path where to extract the archive is not valid

at line 130
public SplFileInfo extractMembers(ResourceInterface $resource, Array $members, String|null $to = null)

Extracts specific members of the archive

Parameters

ResourceInterface $resource The path to the archive
Array $members An array of members
String|null $to The path where to extract the members

Return Value

SplFileInfo The extracted archive

Exceptions

RuntimeException In case of failure
InvalidArgumentException In case no members could be removed or provide extract target direcotry is not valid