11
11
12
12
namespace Alchemy \Zippy \Adapter ;
13
13
14
- use Alchemy \Zippy \Archive \ArchiveInterface ;
15
14
use Alchemy \Zippy \Adapter \Resource \ResourceInterface ;
15
+ use Alchemy \Zippy \Archive \ArchiveInterface ;
16
+ use Alchemy \Zippy \Archive \MemberInterface ;
16
17
use Alchemy \Zippy \Exception \InvalidArgumentException ;
18
+ use Alchemy \Zippy \Exception \NotSupportedException ;
17
19
use Alchemy \Zippy \Exception \RuntimeException ;
18
20
19
21
Interface AdapterInterface
20
22
{
21
23
/**
22
24
* Opens an archive
23
25
*
24
- * @param String $path The path to the archive
26
+ * @param string $path The path to the archive
25
27
*
26
28
* @return ArchiveInterface
27
29
*
28
30
* @throws InvalidArgumentException In case the provided path is not valid
29
- * @throws RuntimeException In case of failure
31
+ * @throws RuntimeException In case of failure
30
32
*/
31
33
public function open ($ path );
32
34
@@ -36,22 +38,22 @@ public function open($path);
36
38
* Please note some adapters can not create empty archives.
37
39
* They would throw a `NotSupportedException` in case you ask to create an archive without files
38
40
*
39
- * @param String $path The path to the archive
40
- * @param String|Array |\Traversable|null $files A filename, an array of files, or a \Traversable instance
41
- * @param Boolean $recursive Whether to recurse or not in the provided directories
41
+ * @param string $path The path to the archive
42
+ * @param string|string[] |\Traversable|null $files A filename, an array of files, or a \Traversable instance
43
+ * @param bool $recursive Whether to recurse or not in the provided directories
42
44
*
43
45
* @return ArchiveInterface
44
46
*
45
- * @throws RuntimeException In case of failure
46
- * @throws NotSupportedException In case the operation in not supported
47
+ * @throws RuntimeException In case of failure
48
+ * @throws NotSupportedException In case the operation in not supported
47
49
* @throws InvalidArgumentException In case no files could be added
48
50
*/
49
51
public function create ($ path , $ files = null , $ recursive = true );
50
52
51
53
/**
52
54
* Tests if the adapter is supported by the current environment
53
55
*
54
- * @return Boolean
56
+ * @return bool
55
57
*/
56
58
public function isSupported ();
57
59
@@ -60,7 +62,7 @@ public function isSupported();
60
62
*
61
63
* @param ResourceInterface $resource The path to the archive
62
64
*
63
- * @return Array
65
+ * @return array
64
66
*
65
67
* @throws RuntimeException In case of failure
66
68
*/
@@ -69,26 +71,26 @@ public function listMembers(ResourceInterface $resource);
69
71
/**
70
72
* Adds a file to the archive
71
73
*
72
- * @param ResourceInterface $resource The path to the archive
73
- * @param String|Array |\Traversable $files An array of paths to add, relative to cwd
74
- * @param Boolean $recursive Whether or not to recurse in the provided directories
74
+ * @param ResourceInterface $resource The path to the archive
75
+ * @param string|array |\Traversable $files An array of paths to add, relative to cwd
76
+ * @param bool $recursive Whether or not to recurse in the provided directories
75
77
*
76
- * @return Array
78
+ * @return array
77
79
*
78
- * @throws RuntimeException In case of failure
80
+ * @throws RuntimeException In case of failure
79
81
* @throws InvalidArgumentException In case no files could be added
80
82
*/
81
83
public function add (ResourceInterface $ resource , $ files , $ recursive = true );
82
84
83
85
/**
84
86
* Removes a member of the archive
85
87
*
86
- * @param ResourceInterface $resource The path to the archive
87
- * @param String|Array|\Traversable $files A filename, an array of files, or a \Traversable instance
88
+ * @param ResourceInterface $resource The path to the archive
89
+ * @param String|Array|\Traversable $files A filename, an array of files, or a \Traversable instance
88
90
*
89
91
* @return Array
90
92
*
91
- * @throws RuntimeException In case of failure
93
+ * @throws RuntimeException In case of failure
92
94
* @throws InvalidArgumentException In case no files could be removed
93
95
*/
94
96
public function remove (ResourceInterface $ resource , $ files );
@@ -99,11 +101,11 @@ public function remove(ResourceInterface $resource, $files);
99
101
* Note that any existing files will be overwritten by the adapter
100
102
*
101
103
* @param ResourceInterface $resource The path to the archive
102
- * @param String |null $to The path where to extract the archive
104
+ * @param string |null $to The path where to extract the archive
103
105
*
104
106
* @return \SplFileInfo The extracted archive
105
107
*
106
- * @throws RuntimeException In case of failure
108
+ * @throws RuntimeException In case of failure
107
109
* @throws InvalidArgumentException In case the provided path where to extract the archive is not valid
108
110
*/
109
111
public function extract (ResourceInterface $ resource , $ to = null );
@@ -112,15 +114,16 @@ public function extract(ResourceInterface $resource, $to = null);
112
114
* Extracts specific members of the archive
113
115
*
114
116
* @param ResourceInterface $resource The path to the archive
115
- * @param Array $members An array of members
116
- * @param String|null $to The path where to extract the members
117
+ * @param string|string[] $members A path or array of paths matching the members to extract from the resource.
118
+ * @param string|null $to The path where to extract the members
119
+ * @param bool $overwrite Whether to overwrite existing files in target directory
117
120
*
118
121
* @return \SplFileInfo The extracted archive
119
122
*
120
- * @throws RuntimeException In case of failure
121
- * @throws InvalidArgumentException In case no members could be removed or provide extract target directory is not valid
123
+ * @throws RuntimeException In case of failure
124
+ * @throws InvalidArgumentException In case no members could be removed or providedd extract target directory is not valid
122
125
*/
123
- public function extractMembers (ResourceInterface $ resource , $ members , $ to = null );
126
+ public function extractMembers (ResourceInterface $ resource , $ members , $ to = null , $ overwrite = false );
124
127
125
128
/**
126
129
* Returns the adapter name
0 commit comments