Skip to content

Commit eba9f8b

Browse files
authored
Merge pull request #146 from PHPJasper/develop
Develop
2 parents 3c79a6d + ef88341 commit eba9f8b

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/PHPJasper.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
namespace PHPJasper;
1515

16+
use PHPJasper\Exception;
17+
1618
class PHPJasper
1719
{
1820

@@ -68,7 +70,7 @@ private function checkServer()
6870
public function compile(string $input, string $output = '')
6971
{
7072
if (!is_file($input)) {
71-
throw new \PHPJasper\Exception\InvalidInputFile();
73+
throw new Exception\InvalidInputFile();
7274
}
7375

7476
$this->command = $this->checkServer();
@@ -95,7 +97,7 @@ public function process(string $input, string $output, array $options = [])
9597
$options = $this->parseProcessOptions($options);
9698

9799
if (!$input) {
98-
throw new \PHPJasper\Exception\InvalidInputFile();
100+
throw new Exception\InvalidInputFile();
99101
}
100102

101103
$this->validateFormat($options['format']);
@@ -175,7 +177,7 @@ protected function validateFormat($format)
175177
}
176178
foreach ($format as $value) {
177179
if (!in_array($value, $this->formats)) {
178-
throw new \PHPJasper\Exception\InvalidFormat();
180+
throw new Exception\InvalidFormat();
179181
}
180182
}
181183
}
@@ -188,7 +190,7 @@ protected function validateFormat($format)
188190
public function listParameters(string $input)
189191
{
190192
if (!is_file($input)) {
191-
throw new \PHPJasper\Exception\InvalidInputFile();
193+
throw new Exception\InvalidInputFile();
192194
}
193195

194196
$this->command = $this->checkServer();
@@ -216,7 +218,7 @@ public function execute($user = false)
216218
chdir($this->pathExecutable);
217219
exec($this->command, $output, $returnVar);
218220
if ($returnVar !== 0) {
219-
throw new \PHPJasper\Exception\ErrorCommandExecutable();
221+
throw new Exception\ErrorCommandExecutable();
220222
}
221223

222224
return $output;
@@ -247,10 +249,10 @@ protected function addUserToCommand($user)
247249
protected function validateExecute()
248250
{
249251
if (!$this->command) {
250-
throw new \PHPJasper\Exception\InvalidCommandExecutable();
252+
throw new Exception\InvalidCommandExecutable();
251253
}
252254
if (!is_dir($this->pathExecutable)) {
253-
throw new \PHPJasper\Exception\InvalidResourceDirectory();
255+
throw new Exception\InvalidResourceDirectory();
254256
}
255257
}
256258
}

tests/PHPJasperTest.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,13 @@
1515

1616
use PHPUnit\Framework\TestCase;
1717
use PHPJasper\PHPJasper;
18+
use PHPJasper\Exception;
1819

1920
/**
2021
* @author Rafael Queiroz <[email protected]>
2122
*/
2223
final class PHPJasperTest extends TestCase
2324
{
24-
/**
25-
* @var
26-
*/
2725
private $instance;
2826

2927
public function setUp()
@@ -72,7 +70,7 @@ public function testListParameters()
7270

7371
public function testCompileWithWrongInput()
7472
{
75-
$this->expectException(\PHPJasper\Exception\InvalidInputFile::class);
73+
$this->expectException(Exception\InvalidInputFile::class);
7674

7775
$this->instance->compile('');
7876
}
@@ -86,14 +84,14 @@ public function testCompileHelloWorld()
8684

8785
public function testExecuteWithoutCompile()
8886
{
89-
$this->expectException(\PHPJasper\Exception\InvalidCommandExecutable::class);
87+
$this->expectException(Exception\InvalidCommandExecutable::class);
9088

9189
$this->instance->execute();
9290
}
9391

9492
public function testInvalidInputFile()
9593
{
96-
$this->expectException(\PHPJasper\Exception\InvalidInputFile::class);
94+
$this->expectException(Exception\InvalidInputFile::class);
9795

9896
$this->instance->compile('{invalid}')->execute();
9997
}
@@ -107,14 +105,14 @@ public function testExecute()
107105

108106
public function testListParametersWithWrongInput()
109107
{
110-
$this->expectException(\PHPJasper\Exception\InvalidInputFile::class);
108+
$this->expectException(Exception\InvalidInputFile::class);
111109

112110
$this->instance->listParameters('');
113111
}
114112

115113
public function testProcessWithWrongInput()
116114
{
117-
$this->expectException(\PHPJasper\Exception\InvalidInputFile::class);
115+
$this->expectException(Exception\InvalidInputFile::class);
118116

119117
$this->instance->process('', '', [
120118
'format' => 'mp3'
@@ -123,7 +121,7 @@ public function testProcessWithWrongInput()
123121

124122
public function testProcessWithWrongFormat()
125123
{
126-
$this->expectException(\PHPJasper\Exception\InvalidFormat::class);
124+
$this->expectException(Exception\InvalidFormat::class);
127125

128126
$this->instance->process('hello_world.jrxml', '', [
129127
'format' => 'mp3'

0 commit comments

Comments
 (0)