|
15 | 15 |
|
16 | 16 | use PHPJasper\Exception;
|
17 | 17 |
|
| 18 | +use function strtoupper; |
| 19 | +use function substr; |
| 20 | +use function is_file; |
| 21 | +use function realpath; |
| 22 | +use function join; |
| 23 | +use function array_merge; |
| 24 | +use function is_array; |
| 25 | +use function in_array; |
| 26 | +use function chdir; |
| 27 | +use function exec; |
| 28 | +use function is_dir; |
| 29 | + |
18 | 30 | class PHPJasper
|
19 | 31 | {
|
20 | 32 |
|
@@ -127,6 +139,7 @@ public function process(string $input, string $output, array $options = [])
|
127 | 139 | $this->command .= ' -o ' . "\"$output\"";
|
128 | 140 |
|
129 | 141 | $this->command .= ' -f ' . join(' ', $options['format']);
|
| 142 | + |
130 | 143 | if ($options['params']) {
|
131 | 144 | $this->command .= ' -P ';
|
132 | 145 | foreach ($options['params'] as $key => $value) {
|
@@ -189,6 +202,7 @@ protected function validateFormat($format)
|
189 | 202 | if (!is_array($format)) {
|
190 | 203 | $format = [$format];
|
191 | 204 | }
|
| 205 | + |
192 | 206 | foreach ($format as $value) {
|
193 | 207 | if (!in_array($value, $this->formats)) {
|
194 | 208 | throw new Exception\InvalidFormat();
|
@@ -231,6 +245,7 @@ public function execute($user = false)
|
231 | 245 |
|
232 | 246 | chdir($this->pathExecutable);
|
233 | 247 | exec($this->command, $output, $returnVar);
|
| 248 | + |
234 | 249 | if ($returnVar !== 0) {
|
235 | 250 | throw new Exception\ErrorCommandExecutable();
|
236 | 251 | }
|
@@ -275,6 +290,7 @@ protected function validateExecute()
|
275 | 290 | if (!$this->command) {
|
276 | 291 | throw new Exception\InvalidCommandExecutable();
|
277 | 292 | }
|
| 293 | + |
278 | 294 | if (!is_dir($this->pathExecutable)) {
|
279 | 295 | throw new Exception\InvalidResourceDirectory();
|
280 | 296 | }
|
|
0 commit comments