@@ -62,30 +62,30 @@ discard block |
||
62 | 62 | $process->setTimeout(3600); |
63 | 63 | $process->setIdleTimeout(3600); |
64 | 64 | |
65 | - if ($stream == 1) |
|
66 | - { |
|
67 | - return $this->stream_to_file($process, $stdoutfile, $stderrfile); |
|
68 | - } |
|
69 | - |
|
70 | - if ($stream == 2) |
|
71 | - { |
|
72 | - return $this->stream_to_stdout($process); |
|
73 | - } |
|
74 | - |
|
75 | - if ($stream == 3) |
|
76 | - { |
|
77 | - return $this->stream_to_both($process, $stdoutfile, $stderrfile); |
|
78 | - } |
|
79 | - |
|
80 | - if ($stream == 4) |
|
81 | - { |
|
82 | - return $this->stream_stdout_wait($process, $fail_on_error); |
|
83 | - } |
|
84 | - |
|
85 | - if ($stream == 5) |
|
86 | - { |
|
87 | - return $this->stream_stdout_tty($process); |
|
88 | - } |
|
65 | + if ($stream == 1) |
|
66 | + { |
|
67 | + return $this->stream_to_file($process, $stdoutfile, $stderrfile); |
|
68 | + } |
|
69 | + |
|
70 | + if ($stream == 2) |
|
71 | + { |
|
72 | + return $this->stream_to_stdout($process); |
|
73 | + } |
|
74 | + |
|
75 | + if ($stream == 3) |
|
76 | + { |
|
77 | + return $this->stream_to_both($process, $stdoutfile, $stderrfile); |
|
78 | + } |
|
79 | + |
|
80 | + if ($stream == 4) |
|
81 | + { |
|
82 | + return $this->stream_stdout_wait($process, $fail_on_error); |
|
83 | + } |
|
84 | + |
|
85 | + if ($stream == 5) |
|
86 | + { |
|
87 | + return $this->stream_stdout_tty($process); |
|
88 | + } |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | file_put_contents($GLOBALS['stderrfile'], $buffer, FILE_APPEND | LOCK_EX); |
115 | 115 | } |
116 | 116 | |
117 | - if ($GLOBALS['stderrfile'] === null) |
|
117 | + if ($GLOBALS['stderrfile'] === null) |
|
118 | 118 | { |
119 | 119 | file_put_contents($GLOBALS['stdoutfile'], $buffer, FILE_APPEND | LOCK_EX); |
120 | 120 | } |
@@ -175,14 +175,14 @@ discard block |
||
175 | 175 | file_put_contents($GLOBALS['stderrfile'], $buffer, FILE_APPEND | LOCK_EX); |
176 | 176 | } |
177 | 177 | |
178 | - if ($GLOBALS['stderrfile'] === null) |
|
178 | + if ($GLOBALS['stderrfile'] === null) |
|
179 | 179 | { |
180 | 180 | file_put_contents($GLOBALS['stdoutfile'], $buffer, FILE_APPEND | LOCK_EX); |
181 | 181 | } |
182 | 182 | fwrite(STDERR, $buffer); |
183 | 183 | } |
184 | 184 | |
185 | - if (Process::ERR !== $type) |
|
185 | + if (Process::ERR !== $type) |
|
186 | 186 | { |
187 | 187 | file_put_contents($GLOBALS['stdoutfile'], $buffer, FILE_APPEND | LOCK_EX); |
188 | 188 | fwrite(STDOUT, $buffer); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | $GLOBALS['stdoutfile'] = $stdoutfile; |
107 | 107 | $GLOBALS['stderrfile'] = $stderrfile; |
108 | 108 | |
109 | - $process->run(function ($type, $buffer) { |
|
109 | + $process->run(function($type, $buffer) { |
|
110 | 110 | if (Process::ERR === $type) |
111 | 111 | { |
112 | 112 | if ($GLOBALS['stderrfile'] !== null) |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | final protected function stream_to_stdout(Process $process) |
137 | 137 | { |
138 | - $process->run(function ($type, $buffer) { |
|
138 | + $process->run(function($type, $buffer) { |
|
139 | 139 | if (Process::ERR === $type) |
140 | 140 | { |
141 | 141 | fwrite(STDERR, $buffer); |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | $GLOBALS['stdoutfile'] = $stdoutfile; |
168 | 168 | $GLOBALS['stderrfile'] = $stderrfile; |
169 | 169 | |
170 | - $process->run(function ($type, $buffer) { |
|
170 | + $process->run(function($type, $buffer) { |
|
171 | 171 | if (Process::ERR === $type) |
172 | 172 | { |
173 | 173 | if ($GLOBALS['stderrfile'] !== null) |
@@ -155,10 +155,10 @@ discard block |
||
155 | 155 | continue; |
156 | 156 | } |
157 | 157 | } |
158 | - return true; |
|
158 | + return true; |
|
159 | 159 | } |
160 | 160 | |
161 | - /** |
|
161 | + /** |
|
162 | 162 | * Returns pathnames matching a pattern (for files only & hidden files). |
163 | 163 | * |
164 | 164 | * @param string $directory directory |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | return false; |
173 | 173 | } |
174 | 174 | |
175 | - $pattern = is_array(($pattern)) ? '{' . implode(',', $pattern) . '}' : $pattern; |
|
175 | + $pattern = is_array(($pattern)) ? '{' . implode(',', $pattern) . '}' : $pattern; |
|
176 | 176 | if ($pattern === null) |
177 | 177 | { |
178 | 178 | return array_diff(glob($directory . '/*'), ['.', '..']); |
@@ -172,12 +172,12 @@ discard block |
||
172 | 172 | return false; |
173 | 173 | } |
174 | 174 | |
175 | - $pattern = is_array(($pattern)) ? '{' . implode(',', $pattern) . '}' : $pattern; |
|
175 | + $pattern = is_array(($pattern)) ? '{'.implode(',', $pattern).'}' : $pattern; |
|
176 | 176 | if ($pattern === null) |
177 | 177 | { |
178 | - return array_diff(glob($directory . '/*'), ['.', '..']); |
|
178 | + return array_diff(glob($directory.'/*'), ['.', '..']); |
|
179 | 179 | } |
180 | - return glob($directory . '/{,.}*' . $pattern . '*', GLOB_BRACE); |
|
180 | + return glob($directory.'/{,.}*'.$pattern.'*', GLOB_BRACE); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | { |
270 | 270 | if ($file != '.' && $file != '..') |
271 | 271 | { |
272 | - $files[] = $directory . '/' . $file; |
|
272 | + $files[] = $directory.'/'.$file; |
|
273 | 273 | } |
274 | 274 | } |
275 | 275 | } |
@@ -9,21 +9,21 @@ discard block |
||
9 | 9 | class Builder |
10 | 10 | { |
11 | 11 | |
12 | - /** |
|
12 | + /** |
|
13 | 13 | * Command prefix. |
14 | 14 | * |
15 | 15 | * @var string |
16 | 16 | */ |
17 | - public $prefix; |
|
17 | + public $prefix; |
|
18 | 18 | |
19 | - /** |
|
19 | + /** |
|
20 | 20 | * Command options. |
21 | 21 | * |
22 | 22 | * @var array |
23 | 23 | */ |
24 | 24 | public $options; |
25 | 25 | |
26 | - /** |
|
26 | + /** |
|
27 | 27 | * Command arguments. |
28 | 28 | * |
29 | 29 | * @var array |
@@ -65,16 +65,16 @@ discard block |
||
65 | 65 | { |
66 | 66 | $this->options = []; |
67 | 67 | foreach ($opts as $key => $value) |
68 | - { |
|
69 | - if (preg_match('/^-.*$/', $key, $matches)) |
|
70 | - { |
|
71 | - $this->options[] = is_bool($value) ? $key : str_pad($key, strlen($key) + 1, ' ', STR_PAD_RIGHT) . $value; |
|
72 | - } |
|
73 | - if (preg_match('/^-.*$/', $value, $matches)) |
|
74 | - { |
|
75 | - $this->options[] = $value; |
|
76 | - } |
|
77 | - } |
|
68 | + { |
|
69 | + if (preg_match('/^-.*$/', $key, $matches)) |
|
70 | + { |
|
71 | + $this->options[] = is_bool($value) ? $key : str_pad($key, strlen($key) + 1, ' ', STR_PAD_RIGHT) . $value; |
|
72 | + } |
|
73 | + if (preg_match('/^-.*$/', $value, $matches)) |
|
74 | + { |
|
75 | + $this->options[] = $value; |
|
76 | + } |
|
77 | + } |
|
78 | 78 | $this->options = implode(' ', array_filter($this->options, 'strlen')); |
79 | 79 | return $this; |
80 | 80 | } |
@@ -87,19 +87,19 @@ discard block |
||
87 | 87 | */ |
88 | 88 | final public function setArguments(array $args) |
89 | 89 | { |
90 | - $this->arguments = []; |
|
90 | + $this->arguments = []; |
|
91 | 91 | foreach ($args as $key => $value) |
92 | - { |
|
93 | - if (preg_match('/^-.*$/', $key, $matches)) |
|
94 | - { |
|
95 | - $this->arguments[] = is_bool($value) ? $key : str_pad($key, strlen($key) + 1, ' ', STR_PAD_RIGHT) . $value; |
|
96 | - } |
|
97 | - else |
|
98 | - { |
|
99 | - $this->arguments[] = is_array($value) ? implode(' ', $value) : $value; |
|
100 | - } |
|
101 | - } |
|
102 | - $this->arguments = implode(' ', array_filter($this->arguments, 'strlen')); |
|
92 | + { |
|
93 | + if (preg_match('/^-.*$/', $key, $matches)) |
|
94 | + { |
|
95 | + $this->arguments[] = is_bool($value) ? $key : str_pad($key, strlen($key) + 1, ' ', STR_PAD_RIGHT) . $value; |
|
96 | + } |
|
97 | + else |
|
98 | + { |
|
99 | + $this->arguments[] = is_array($value) ? implode(' ', $value) : $value; |
|
100 | + } |
|
101 | + } |
|
102 | + $this->arguments = implode(' ', array_filter($this->arguments, 'strlen')); |
|
103 | 103 | return $this; |
104 | 104 | } |
105 | 105 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | { |
69 | 69 | if (preg_match('/^-.*$/', $key, $matches)) |
70 | 70 | { |
71 | - $this->options[] = is_bool($value) ? $key : str_pad($key, strlen($key) + 1, ' ', STR_PAD_RIGHT) . $value; |
|
71 | + $this->options[] = is_bool($value) ? $key : str_pad($key, strlen($key) + 1, ' ', STR_PAD_RIGHT).$value; |
|
72 | 72 | } |
73 | 73 | if (preg_match('/^-.*$/', $value, $matches)) |
74 | 74 | { |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | { |
93 | 93 | if (preg_match('/^-.*$/', $key, $matches)) |
94 | 94 | { |
95 | - $this->arguments[] = is_bool($value) ? $key : str_pad($key, strlen($key) + 1, ' ', STR_PAD_RIGHT) . $value; |
|
95 | + $this->arguments[] = is_bool($value) ? $key : str_pad($key, strlen($key) + 1, ' ', STR_PAD_RIGHT).$value; |
|
96 | 96 | } |
97 | 97 | else |
98 | 98 | { |
@@ -93,8 +93,7 @@ |
||
93 | 93 | if (preg_match('/^-.*$/', $key, $matches)) |
94 | 94 | { |
95 | 95 | $this->arguments[] = is_bool($value) ? $key : str_pad($key, strlen($key) + 1, ' ', STR_PAD_RIGHT) . $value; |
96 | - } |
|
97 | - else |
|
96 | + } else |
|
98 | 97 | { |
99 | 98 | $this->arguments[] = is_array($value) ? implode(' ', $value) : $value; |
100 | 99 | } |
@@ -12,194 +12,194 @@ |
||
12 | 12 | class Archive |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * Archive filename. |
|
17 | - * |
|
18 | - * @var string |
|
19 | - */ |
|
20 | - private $archive; |
|
21 | - |
|
22 | - /** |
|
23 | - * Files to archive. |
|
24 | - * |
|
25 | - * @var array |
|
26 | - */ |
|
27 | - private $files = []; |
|
28 | - |
|
29 | - /** |
|
30 | - * Archive command. |
|
31 | - * |
|
32 | - * @var string |
|
33 | - */ |
|
34 | - public $command = ''; |
|
35 | - |
|
36 | - /** |
|
37 | - * Strict error checking. |
|
38 | - * |
|
39 | - * @var boolean |
|
40 | - */ |
|
41 | - public $strict = false; |
|
42 | - |
|
43 | - /** |
|
44 | - * Constructor. |
|
45 | - * |
|
46 | - * @param string $archive archive filename |
|
47 | - * @return void |
|
48 | - */ |
|
49 | - public function __construct($archive) |
|
50 | - { |
|
51 | - $this->archive = $archive; |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * Convert object of class to string. |
|
56 | - * |
|
57 | - * @return string |
|
58 | - */ |
|
59 | - public function __toString() |
|
60 | - { |
|
61 | - return (string) $this->command; |
|
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * Add files to archive file. |
|
66 | - * |
|
67 | - * @param mixed $files files to archive |
|
68 | - * @return object |
|
69 | - */ |
|
70 | - final public function add_files($files) |
|
71 | - { |
|
72 | - $this->files = $files; |
|
73 | - return $this; |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * Returns files to be added to archive file. |
|
78 | - * |
|
79 | - * @return array files to add to archive file |
|
80 | - */ |
|
81 | - final public function get_files() |
|
82 | - { |
|
83 | - return is_array($this->files) ? $this->files : [$this->files]; |
|
84 | - } |
|
85 | - |
|
86 | - /** |
|
87 | - * Returns archive file info (zip). |
|
88 | - * |
|
89 | - * @param array $options supported zip command options. |
|
90 | - * @return string STDOUT of zipinfo |
|
91 | - */ |
|
92 | - final public function zipinfo(array $options = []) |
|
93 | - { |
|
94 | - $this->command = (new Builder()) |
|
95 | - ->setPrefix('zipinfo') |
|
96 | - ->setOptions($options) |
|
97 | - ->setArguments([$this->archive]); |
|
98 | - |
|
99 | - $process = (new Subprocess())->subprocess($this->command); |
|
100 | - $stdout = $process['stdout']; |
|
101 | - $stderr = $process['stderr']; |
|
102 | - $retval = $process['error_code'][0]; |
|
103 | - |
|
104 | - if ($retval != 0) |
|
105 | - { |
|
106 | - throw new \RuntimeException(empty($stderr) ? $stdout : $stderr); |
|
107 | - } |
|
108 | - return $stdout; |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Create archive file (zip). |
|
113 | - * |
|
114 | - * @param array $options supported zip command options. |
|
115 | - * @return object |
|
116 | - */ |
|
117 | - final public function zip(array $options = [], $strict = false) |
|
118 | - { |
|
119 | - $this->command = (new Builder()) |
|
120 | - ->setPrefix('zip') |
|
121 | - ->setOptions($options) |
|
122 | - ->setArguments([$this->archive, $this->get_files()]); |
|
123 | - $this->strict = $strict; |
|
124 | - return $this; |
|
125 | - } |
|
126 | - |
|
127 | - /** |
|
128 | - * Extract archive file (zip). |
|
129 | - * |
|
130 | - * @param array $options supported zip command options. |
|
131 | - * @param array $arguments supported zip command arguments. |
|
132 | - * @return object |
|
133 | - */ |
|
134 | - final public function unzip(array $options = [], array $arguments = [], $strict = true) |
|
135 | - { |
|
136 | - $this->command = (new Builder()) |
|
137 | - ->setPrefix('unzip') |
|
138 | - ->setOptions($options) |
|
139 | - ->setArguments(array_merge([$this->archive], $arguments)); |
|
140 | - $this->strict = $strict; |
|
141 | - return $this; |
|
142 | - } |
|
143 | - |
|
144 | - /** |
|
145 | - * Create archive file (tar). |
|
146 | - * |
|
147 | - * @param array $options supported tar command options. |
|
148 | - * @param array $arguments supported tar command arguments. |
|
149 | - * @return object |
|
150 | - */ |
|
151 | - final public function tar(array $options = [], array $arguments = [], $strict = true) |
|
152 | - { |
|
153 | - $this->command = (new Builder()) |
|
154 | - ->setPrefix('tar') |
|
155 | - ->setOptions($options) |
|
156 | - ->setArguments(array_merge([$this->archive], $arguments, $this->get_files())); |
|
157 | - $this->strict = $strict; |
|
158 | - return $this; |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * Compresses archive file (xz). |
|
163 | - * |
|
164 | - * @param array $options supported tar command options. |
|
165 | - * @param array $arguments supported tar command arguments. |
|
166 | - * @return object |
|
167 | - */ |
|
168 | - final public function xz(array $options = [], array $arguments = [], $strict = true) |
|
169 | - { |
|
170 | - $this->command = (new Builder()) |
|
171 | - ->setPrefix('xz') |
|
172 | - ->setOptions($options) |
|
173 | - ->setArguments($this->get_files()); |
|
174 | - $this->strict = $strict; |
|
175 | - return $this; |
|
176 | - } |
|
177 | - |
|
178 | - /** |
|
179 | - * Executes archive command.. |
|
180 | - * |
|
181 | - * @return mixed exit status code or false (no files) |
|
182 | - */ |
|
183 | - final public function run() |
|
184 | - { |
|
185 | - $process = (new Subprocess())->subprocess($this->command); |
|
186 | - $stdout = $process['stdout']; |
|
187 | - $stderr = $process['stderr']; |
|
188 | - $retval = $process['error_code'][0]; |
|
189 | - |
|
190 | - if (($this->strict == false || $this->strict) && $retval == 0) |
|
191 | - { |
|
192 | - return true; |
|
193 | - } |
|
194 | - |
|
195 | - if ($this->strict == false && $retval != 0) |
|
196 | - { |
|
197 | - return $retval; |
|
198 | - } |
|
199 | - |
|
200 | - if ($this->strict && $retval != 0) |
|
201 | - { |
|
202 | - throw new \RuntimeException(empty($stderr) ? $stdout : $stderr); |
|
203 | - } |
|
204 | - } |
|
15 | + /** |
|
16 | + * Archive filename. |
|
17 | + * |
|
18 | + * @var string |
|
19 | + */ |
|
20 | + private $archive; |
|
21 | + |
|
22 | + /** |
|
23 | + * Files to archive. |
|
24 | + * |
|
25 | + * @var array |
|
26 | + */ |
|
27 | + private $files = []; |
|
28 | + |
|
29 | + /** |
|
30 | + * Archive command. |
|
31 | + * |
|
32 | + * @var string |
|
33 | + */ |
|
34 | + public $command = ''; |
|
35 | + |
|
36 | + /** |
|
37 | + * Strict error checking. |
|
38 | + * |
|
39 | + * @var boolean |
|
40 | + */ |
|
41 | + public $strict = false; |
|
42 | + |
|
43 | + /** |
|
44 | + * Constructor. |
|
45 | + * |
|
46 | + * @param string $archive archive filename |
|
47 | + * @return void |
|
48 | + */ |
|
49 | + public function __construct($archive) |
|
50 | + { |
|
51 | + $this->archive = $archive; |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * Convert object of class to string. |
|
56 | + * |
|
57 | + * @return string |
|
58 | + */ |
|
59 | + public function __toString() |
|
60 | + { |
|
61 | + return (string) $this->command; |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * Add files to archive file. |
|
66 | + * |
|
67 | + * @param mixed $files files to archive |
|
68 | + * @return object |
|
69 | + */ |
|
70 | + final public function add_files($files) |
|
71 | + { |
|
72 | + $this->files = $files; |
|
73 | + return $this; |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * Returns files to be added to archive file. |
|
78 | + * |
|
79 | + * @return array files to add to archive file |
|
80 | + */ |
|
81 | + final public function get_files() |
|
82 | + { |
|
83 | + return is_array($this->files) ? $this->files : [$this->files]; |
|
84 | + } |
|
85 | + |
|
86 | + /** |
|
87 | + * Returns archive file info (zip). |
|
88 | + * |
|
89 | + * @param array $options supported zip command options. |
|
90 | + * @return string STDOUT of zipinfo |
|
91 | + */ |
|
92 | + final public function zipinfo(array $options = []) |
|
93 | + { |
|
94 | + $this->command = (new Builder()) |
|
95 | + ->setPrefix('zipinfo') |
|
96 | + ->setOptions($options) |
|
97 | + ->setArguments([$this->archive]); |
|
98 | + |
|
99 | + $process = (new Subprocess())->subprocess($this->command); |
|
100 | + $stdout = $process['stdout']; |
|
101 | + $stderr = $process['stderr']; |
|
102 | + $retval = $process['error_code'][0]; |
|
103 | + |
|
104 | + if ($retval != 0) |
|
105 | + { |
|
106 | + throw new \RuntimeException(empty($stderr) ? $stdout : $stderr); |
|
107 | + } |
|
108 | + return $stdout; |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * Create archive file (zip). |
|
113 | + * |
|
114 | + * @param array $options supported zip command options. |
|
115 | + * @return object |
|
116 | + */ |
|
117 | + final public function zip(array $options = [], $strict = false) |
|
118 | + { |
|
119 | + $this->command = (new Builder()) |
|
120 | + ->setPrefix('zip') |
|
121 | + ->setOptions($options) |
|
122 | + ->setArguments([$this->archive, $this->get_files()]); |
|
123 | + $this->strict = $strict; |
|
124 | + return $this; |
|
125 | + } |
|
126 | + |
|
127 | + /** |
|
128 | + * Extract archive file (zip). |
|
129 | + * |
|
130 | + * @param array $options supported zip command options. |
|
131 | + * @param array $arguments supported zip command arguments. |
|
132 | + * @return object |
|
133 | + */ |
|
134 | + final public function unzip(array $options = [], array $arguments = [], $strict = true) |
|
135 | + { |
|
136 | + $this->command = (new Builder()) |
|
137 | + ->setPrefix('unzip') |
|
138 | + ->setOptions($options) |
|
139 | + ->setArguments(array_merge([$this->archive], $arguments)); |
|
140 | + $this->strict = $strict; |
|
141 | + return $this; |
|
142 | + } |
|
143 | + |
|
144 | + /** |
|
145 | + * Create archive file (tar). |
|
146 | + * |
|
147 | + * @param array $options supported tar command options. |
|
148 | + * @param array $arguments supported tar command arguments. |
|
149 | + * @return object |
|
150 | + */ |
|
151 | + final public function tar(array $options = [], array $arguments = [], $strict = true) |
|
152 | + { |
|
153 | + $this->command = (new Builder()) |
|
154 | + ->setPrefix('tar') |
|
155 | + ->setOptions($options) |
|
156 | + ->setArguments(array_merge([$this->archive], $arguments, $this->get_files())); |
|
157 | + $this->strict = $strict; |
|
158 | + return $this; |
|
159 | + } |
|
160 | + |
|
161 | + /** |
|
162 | + * Compresses archive file (xz). |
|
163 | + * |
|
164 | + * @param array $options supported tar command options. |
|
165 | + * @param array $arguments supported tar command arguments. |
|
166 | + * @return object |
|
167 | + */ |
|
168 | + final public function xz(array $options = [], array $arguments = [], $strict = true) |
|
169 | + { |
|
170 | + $this->command = (new Builder()) |
|
171 | + ->setPrefix('xz') |
|
172 | + ->setOptions($options) |
|
173 | + ->setArguments($this->get_files()); |
|
174 | + $this->strict = $strict; |
|
175 | + return $this; |
|
176 | + } |
|
177 | + |
|
178 | + /** |
|
179 | + * Executes archive command.. |
|
180 | + * |
|
181 | + * @return mixed exit status code or false (no files) |
|
182 | + */ |
|
183 | + final public function run() |
|
184 | + { |
|
185 | + $process = (new Subprocess())->subprocess($this->command); |
|
186 | + $stdout = $process['stdout']; |
|
187 | + $stderr = $process['stderr']; |
|
188 | + $retval = $process['error_code'][0]; |
|
189 | + |
|
190 | + if (($this->strict == false || $this->strict) && $retval == 0) |
|
191 | + { |
|
192 | + return true; |
|
193 | + } |
|
194 | + |
|
195 | + if ($this->strict == false && $retval != 0) |
|
196 | + { |
|
197 | + return $retval; |
|
198 | + } |
|
199 | + |
|
200 | + if ($this->strict && $retval != 0) |
|
201 | + { |
|
202 | + throw new \RuntimeException(empty($stderr) ? $stdout : $stderr); |
|
203 | + } |
|
204 | + } |
|
205 | 205 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @param array $arguments supported tar command arguments. |
149 | 149 | * @return object |
150 | 150 | */ |
151 | - final public function tar(array $options = [], array $arguments = [], $strict = true) |
|
151 | + final public function tar(array $options = [], array $arguments = [], $strict = true) |
|
152 | 152 | { |
153 | 153 | $this->command = (new Builder()) |
154 | 154 | ->setPrefix('tar') |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @param array $arguments supported tar command arguments. |
166 | 166 | * @return object |
167 | 167 | */ |
168 | - final public function xz(array $options = [], array $arguments = [], $strict = true) |
|
168 | + final public function xz(array $options = [], array $arguments = [], $strict = true) |
|
169 | 169 | { |
170 | 170 | $this->command = (new Builder()) |
171 | 171 | ->setPrefix('xz') |