4 * This file is part of Zippy.
6 * (c) Alchemy <info@alchemy.fr>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Alchemy\Zippy\Archive;
14 use Alchemy\Zippy\Exception\RuntimeException;
15 use Alchemy\Zippy\Exception\InvalidArgumentException;
17 interface ArchiveInterface extends \IteratorAggregate, \Countable
20 * Adds a file or a folder into the archive
22 * @param string|array|\SplFileInfo $sources The path to the file or a folder
23 * @param bool $recursive Recurse into sub-directories
25 * @return ArchiveInterface
27 * @throws InvalidArgumentException In case the provided source path is not valid
28 * @throws RuntimeException In case of failure
30 public function addMembers($sources, $recursive = true);
33 * Removes a file from the archive
35 * @param string|array $sources The path to an archive or a folder member
37 * @return ArchiveInterface
39 * @throws RuntimeException In case of failure
41 public function removeMembers($sources);
44 * Lists files and directories archive members
46 * @return MemberInterface[] An array of File
48 * @throws RuntimeException In case archive could not be read
50 public function getMembers();
53 * Extracts current archive to the given directory
55 * @param string $toDirectory The path the extracted archive
57 * @return ArchiveInterface
59 * @throws RuntimeException In case archive could not be extracted
61 public function extract($toDirectory);
64 * Extracts specific members from the archive
66 * @param string|MemberInterface[] $members An array of members path
67 * @param string $toDirectory The destination $directory
69 * @return ArchiveInterface
71 * @throws RuntimeException In case member could not be extracted
73 public function extractMembers($members, $toDirectory = null);