Skip to content

Commit ed14365

Browse files
authored
Merge pull request #73 from PHPJasper/develop
general improvements
2 parents 22d3114 + a7d5129 commit ed14365

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/PHPJasper.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ public function __construct()
5555
$this->windows = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? true : false;
5656
}
5757

58+
private function checkServer()
59+
{
60+
return $this->command = $this->windows ? $this->executable : './' . $this->executable;
61+
}
62+
5863
/**
5964
* @param string $input
6065
* @param string $output optional
@@ -63,11 +68,11 @@ public function __construct()
6368
*/
6469
public function compile(string $input, string $output = '')
6570
{
66-
if ( !$input ) {
71+
if (!$input) {
6772
throw new \PHPJasper\Exception\InvalidInputFile();
6873
}
6974

70-
$this->command = $this->windows ? $this->executable : './' . $this->executable;
75+
$this->command = $this->checkServer();
7176
$this->command .= ' compile ';
7277
$this->command .= "\"$input\"";
7378

@@ -90,12 +95,15 @@ public function compile(string $input, string $output = '')
9095
public function process(string $input, string $output, array $options = [])
9196
{
9297
$options = $this->parseProcessOptions($options);
98+
9399
if (!$input) {
94100
throw new \PHPJasper\Exception\InvalidInputFile();
95101
}
102+
96103
$this->validateFormat($options['format']);
97104

98-
$this->command = $this->windows ? $this->executable : './' . $this->executable;
105+
$this->command = $this->checkServer();
106+
99107
if ($options['locale']) {
100108
$this->command .= " --locale {$options['locale']}";
101109
}
@@ -186,7 +194,7 @@ public function listParameters(string $input)
186194
throw new \PHPJasper\Exception\InvalidInputFile();
187195
}
188196

189-
$this->command = $this->windows ? $this->executable : './' . $this->executable;
197+
$this->command = $this->checkServer();
190198
$this->command .= ' list_parameters ';
191199
$this->command .= "\"$input\"";
192200

@@ -249,5 +257,4 @@ protected function validateExecute()
249257
}
250258

251259
}
252-
253260
}

0 commit comments

Comments
 (0)