From a7d512981168511f6ecf24d7c63ca6577f4f65bf Mon Sep 17 00:00:00 2001 From: "Daniel Rodrigues (geekcom)" Date: Thu, 19 Oct 2017 17:04:55 -0300 Subject: [PATCH] general improvements --- src/PHPJasper.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/PHPJasper.php b/src/PHPJasper.php index ef20eff..6080826 100644 --- a/src/PHPJasper.php +++ b/src/PHPJasper.php @@ -55,6 +55,11 @@ public function __construct() $this->windows = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? true : false; } + private function checkServer() + { + return $this->command = $this->windows ? $this->executable : './' . $this->executable; + } + /** * @param string $input * @param string $output optional @@ -63,11 +68,11 @@ public function __construct() */ public function compile(string $input, string $output = '') { - if ( !$input ) { + if (!$input) { throw new \PHPJasper\Exception\InvalidInputFile(); } - $this->command = $this->windows ? $this->executable : './' . $this->executable; + $this->command = $this->checkServer(); $this->command .= ' compile '; $this->command .= "\"$input\""; @@ -90,12 +95,15 @@ public function compile(string $input, string $output = '') public function process(string $input, string $output, array $options = []) { $options = $this->parseProcessOptions($options); + if (!$input) { throw new \PHPJasper\Exception\InvalidInputFile(); } + $this->validateFormat($options['format']); - $this->command = $this->windows ? $this->executable : './' . $this->executable; + $this->command = $this->checkServer(); + if ($options['locale']) { $this->command .= " --locale {$options['locale']}"; } @@ -186,7 +194,7 @@ public function listParameters(string $input) throw new \PHPJasper\Exception\InvalidInputFile(); } - $this->command = $this->windows ? $this->executable : './' . $this->executable; + $this->command = $this->checkServer(); $this->command .= ' list_parameters '; $this->command .= "\"$input\""; @@ -249,5 +257,4 @@ protected function validateExecute() } } - } \ No newline at end of file