1
1
<?php
2
2
namespace JasperPHP ;
3
-
4
3
/**
5
4
* Class JasperPHP
6
- *
7
5
* @package JasperPHP
8
6
*/
9
7
class JasperPHP
10
8
{
11
9
10
+ /**
11
+ * @var string
12
+ */
13
+ protected $ command ;
14
+
12
15
/**
13
16
* @var string
14
17
*/
@@ -24,8 +27,9 @@ class JasperPHP
24
27
*/
25
28
protected $ windows ;
26
29
27
- protected $ the_command ;
28
-
30
+ /**
31
+ * @var array
32
+ */
29
33
protected $ formats = ['pdf ' , 'rtf ' , 'xls ' , 'xlsx ' , 'docx ' , 'odt ' , 'ods ' , 'pptx ' , 'csv ' , 'html ' , 'xhtml ' , 'xml ' , 'jrprint ' ];
30
34
31
35
/**
@@ -50,12 +54,12 @@ public function compile($input_file, $output_file = false)
50
54
throw new \JasperPHP \Exception \InvalidInputFile ();
51
55
}
52
56
53
- $ this ->the_command = $ this ->windows ? $ this ->executable : './ ' . $ this ->executable ;
54
- $ this ->the_command .= ' compile ' ;
55
- $ this ->the_command .= "\"$ input_file \"" ;
57
+ $ this ->command = $ this ->windows ? $ this ->executable : './ ' . $ this ->executable ;
58
+ $ this ->command .= ' compile ' ;
59
+ $ this ->command .= "\"$ input_file \"" ;
56
60
57
61
if ($ output_file !== false ) {
58
- $ this ->the_command .= ' -o ' . "\"$ output_file \"" ;
62
+ $ this ->command .= ' -o ' . "\"$ output_file \"" ;
59
63
}
60
64
61
65
return $ this ;
@@ -159,7 +163,7 @@ public function process($input_file, $output_file = false, $format = ['pdf'], $p
159
163
}
160
164
}
161
165
162
- $ this ->the_command = $ command ;
166
+ $ this ->command = $ command ;
163
167
164
168
return $ this ;
165
169
}
@@ -176,16 +180,11 @@ public function list_parameters($input_file)
176
180
177
181
$ command .= "\"$ input_file \"" ;
178
182
179
- $ this ->the_command = $ command ;
183
+ $ this ->command = $ command ;
180
184
181
185
return $ this ;
182
186
}
183
187
184
- public function output ()
185
- {
186
- return $ this ->the_command ;
187
- }
188
-
189
188
/**
190
189
* @param bool $user
191
190
* @return mixed
@@ -198,26 +197,33 @@ public function execute($user = false)
198
197
$ this ->validateExecute ();
199
198
$ this ->addUserToCommand ($ user );
200
199
201
- $ command = $ this ->the_command ;
202
200
$ output = [];
203
201
$ return_var = 0 ;
204
202
205
203
chdir ($ this ->path_executable );
206
- exec ($ command , $ output , $ return_var );
204
+ exec ($ this -> command , $ output , $ return_var );
207
205
if ($ return_var !== 0 ) {
208
206
throw new \JasperPHP \Exception \ErrorCommandExecutable ();
209
207
}
210
208
211
209
return $ output ;
212
210
}
213
211
212
+ /**
213
+ * @return string
214
+ */
215
+ public function output ()
216
+ {
217
+ return $ this ->command ;
218
+ }
219
+
214
220
/**
215
221
* @param $user
216
222
*/
217
223
protected function addUserToCommand ($ user )
218
224
{
219
225
if ($ user && !$ this ->windows ) {
220
- $ this ->the_command = 'su -u ' . $ user . " -c \"" . $ this ->the_command . "\"" ;
226
+ $ this ->command = 'su -u ' . $ user . " -c \"" . $ this ->command . "\"" ;
221
227
}
222
228
}
223
229
@@ -227,7 +233,7 @@ protected function addUserToCommand($user)
227
233
*/
228
234
protected function validateExecute ()
229
235
{
230
- if (!$ this ->the_command ) {
236
+ if (!$ this ->command ) {
231
237
throw new \JasperPHP \Exception \InvalidCommandExecutable ();
232
238
}
233
239
if (!is_dir ($ this ->path_executable )) {
0 commit comments