11<?php
22namespace JasperPHP ;
3-
43/**
54 * Class JasperPHP
6- *
75 * @package JasperPHP
86 */
97class JasperPHP
108{
119
10+ /**
11+ * @var string
12+ */
13+ protected $ command ;
14+
1215 /**
1316 * @var string
1417 */
@@ -24,8 +27,9 @@ class JasperPHP
2427 */
2528 protected $ windows ;
2629
27- protected $ the_command ;
28-
30+ /**
31+ * @var array
32+ */
2933 protected $ formats = ['pdf ' , 'rtf ' , 'xls ' , 'xlsx ' , 'docx ' , 'odt ' , 'ods ' , 'pptx ' , 'csv ' , 'html ' , 'xhtml ' , 'xml ' , 'jrprint ' ];
3034
3135 /**
@@ -50,12 +54,12 @@ public function compile($input_file, $output_file = false)
5054 throw new \JasperPHP \Exception \InvalidInputFile ();
5155 }
5256
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 \"" ;
5660
5761 if ($ output_file !== false ) {
58- $ this ->the_command .= ' -o ' . "\"$ output_file \"" ;
62+ $ this ->command .= ' -o ' . "\"$ output_file \"" ;
5963 }
6064
6165 return $ this ;
@@ -159,7 +163,7 @@ public function process($input_file, $output_file = false, $format = ['pdf'], $p
159163 }
160164 }
161165
162- $ this ->the_command = $ command ;
166+ $ this ->command = $ command ;
163167
164168 return $ this ;
165169 }
@@ -176,16 +180,11 @@ public function list_parameters($input_file)
176180
177181 $ command .= "\"$ input_file \"" ;
178182
179- $ this ->the_command = $ command ;
183+ $ this ->command = $ command ;
180184
181185 return $ this ;
182186 }
183187
184- public function output ()
185- {
186- return $ this ->the_command ;
187- }
188-
189188 /**
190189 * @param bool $user
191190 * @return mixed
@@ -198,26 +197,33 @@ public function execute($user = false)
198197 $ this ->validateExecute ();
199198 $ this ->addUserToCommand ($ user );
200199
201- $ command = $ this ->the_command ;
202200 $ output = [];
203201 $ return_var = 0 ;
204202
205203 chdir ($ this ->path_executable );
206- exec ($ command , $ output , $ return_var );
204+ exec ($ this -> command , $ output , $ return_var );
207205 if ($ return_var !== 0 ) {
208206 throw new \JasperPHP \Exception \ErrorCommandExecutable ();
209207 }
210208
211209 return $ output ;
212210 }
213211
212+ /**
213+ * @return string
214+ */
215+ public function output ()
216+ {
217+ return $ this ->command ;
218+ }
219+
214220 /**
215221 * @param $user
216222 */
217223 protected function addUserToCommand ($ user )
218224 {
219225 if ($ user && !$ this ->windows ) {
220- $ this ->the_command = 'su -u ' . $ user . " -c \"" . $ this ->the_command . "\"" ;
226+ $ this ->command = 'su -u ' . $ user . " -c \"" . $ this ->command . "\"" ;
221227 }
222228 }
223229
@@ -227,7 +233,7 @@ protected function addUserToCommand($user)
227233 */
228234 protected function validateExecute ()
229235 {
230- if (!$ this ->the_command ) {
236+ if (!$ this ->command ) {
231237 throw new \JasperPHP \Exception \InvalidCommandExecutable ();
232238 }
233239 if (!is_dir ($ this ->path_executable )) {
0 commit comments