6
6
/**
7
7
* Command
8
8
*
9
- * This class represents an pdftk shell command. It extends a standard shellcommand
10
- * and adds pdftk specific features to add options and operations.
9
+ * This class represents an pdftk shell command. It extends a standard
10
+ * shellcommand and adds pdftk specific features to add options and operations.
11
11
*
12
12
* @author Michael Härtl <haertl.mike@gmail.com>
13
13
* @license http://www.opensource.org/licenses/MIT
@@ -20,12 +20,14 @@ class Command extends BaseCommand
20
20
protected $ _command = 'pdftk ' ;
21
21
22
22
/**
23
- * @var array list of input files to process as array('name' => $filename, 'password' => $pw) indexed by handle
23
+ * @var array list of input files to process as array('name' => $filename,
24
+ * 'password' => $pw) indexed by handle
24
25
*/
25
26
protected $ _files = array ();
26
27
27
28
/**
28
- * @var array list of command options, either strings or array with arguments to addArg()
29
+ * @var array list of command options, either strings or array with
30
+ * arguments to addArg()
29
31
*/
30
32
protected $ _options = array ();
31
33
@@ -35,21 +37,24 @@ class Command extends BaseCommand
35
37
protected $ _operation ;
36
38
37
39
/**
38
- * @var string|array operation arguments, e.g. a list of page ranges or a filename or tmp file instance
40
+ * @var string|array operation arguments, e.g. a list of page ranges or a
41
+ * filename or tmp file instance
39
42
*/
40
43
protected $ _operationArgument = array ();
41
44
42
45
/**
43
- * @var bool whether to force escaping of the operation argument e.g. for filenames
46
+ * @var bool whether to force escaping of the operation argument e.g. for
47
+ * filenames
44
48
*/
45
49
protected $ _escapeOperationArgument = false ;
46
50
47
51
/**
48
52
* @param string $name the PDF file to add for processing
49
- * @param string $handle one or more uppercase letters A..Z to reference this file later.
53
+ * @param string $handle one or more uppercase letters A..Z to reference
54
+ * this file later.
50
55
* @param string|null $password the owner (or user) password if any
51
- * @throws \Exception
52
56
* @return Command the command instance for method chaining
57
+ * @throws \Exception
53
58
*/
54
59
public function addFile ($ name , $ handle , $ password = null )
55
60
{
@@ -64,8 +69,10 @@ public function addFile($name, $handle, $password = null)
64
69
65
70
/**
66
71
* @param string $option the pdftk option to add
67
- * @param string|File|null $argument the argument to add, either string, File instance or null if none
68
- * @param null|bool whether to escape the option. Default is null meaning use Command default setting.
72
+ * @param string|File|null $argument the argument to add, either string,
73
+ * File instance or null if none
74
+ * @param null|bool whether to escape the option. Default is null meaning
75
+ * use Command default setting.
69
76
* @return Command the command instance for method chaining
70
77
*/
71
78
public function addOption ($ option , $ argument = null , $ escape = null )
@@ -107,7 +114,8 @@ public function setOperationArgument($value, $escape = false)
107
114
}
108
115
109
116
/**
110
- * @return string|array|null the current operation argument as string or array or null if none set
117
+ * @return string|array|null the current operation argument as string or
118
+ * array or null if none set
111
119
*/
112
120
public function getOperationArgument ()
113
121
{
@@ -126,11 +134,15 @@ public function getFileCount()
126
134
/**
127
135
* Add a page range as used by some operations
128
136
*
129
- * @param int|string|array $start the start page number or an array of page numbers. If an array, the other
130
- * arguments will be ignored. $start can also be bigger than $end for pages in reverse order.
131
- * @param int|string|null $end the end page number or null for single page (or list if $start is an array)
132
- * @param string|null $handle the handle of the file to use. Can be null if only a single file was added.
133
- * @param string|null $qualifier the page number qualifier, either 'even' or 'odd' or null for none
137
+ * @param int|string|array $start the start page number or an array of page
138
+ * numbers. If an array, the other arguments will be ignored. $start can
139
+ * also be bigger than $end for pages in reverse order.
140
+ * @param int|string|null $end the end page number or null for single page
141
+ * (or list if $start is an array)
142
+ * @param string|null $handle the handle of the file to use. Can be null if
143
+ * only a single file was added.
144
+ * @param string|null $qualifier the page number qualifier, either 'even'
145
+ * or 'odd' or null for none
134
146
* @param string $rotation the rotation to apply to the pages.
135
147
* @return Command the command instance for method chaining
136
148
*/
@@ -154,7 +166,8 @@ public function addPageRange($start, $end = null, $handle = null, $qualifier = n
154
166
}
155
167
156
168
/**
157
- * @param string|null $filename the filename to add as 'output' option or null if none
169
+ * @param string|null $filename the filename to add as 'output' option or
170
+ * null if none
158
171
* @return bool whether the command was executed successfully
159
172
*/
160
173
public function execute ($ filename = null )
@@ -188,7 +201,8 @@ protected function processInputFiles()
188
201
189
202
/**
190
203
* Process options and create respective command arguments
191
- * @param string|null $filename if provided an 'output' option will be added
204
+ * @param string|null $filename if provided an 'output' option will be
205
+ * added
192
206
*/
193
207
protected function processOptions ($ filename = null )
194
208
{
@@ -220,7 +234,9 @@ protected function processOperation()
220
234
}
221
235
222
236
/**
223
- * Ensure that the command was not exectued yet. Throws exception otherwise.
237
+ * Ensure that the command was not exectued yet. Throws exception
238
+ * otherwise.
239
+ * @throws \Exception
224
240
*/
225
241
protected function checkExecutionStatus ()
226
242
{
0 commit comments