Skip to content

Commit d3c86ca

Browse files
committed
Refactor in JasperPHP::__construct()
1 parent 2932178 commit d3c86ca

File tree

2 files changed

+40
-31
lines changed

2 files changed

+40
-31
lines changed

src/JasperPHP.php

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,40 @@
11
<?php
2-
32
namespace JasperPHP;
4-
3+
/**
4+
* Class JasperPHP
5+
*
6+
* @package JasperPHP
7+
*/
58
class JasperPHP
69
{
7-
protected $executable = 'jasperstarter'; //executable jasperstarter
10+
11+
/**
12+
* @var string
13+
*/
14+
protected $executable;
15+
16+
/**
17+
* @var string
18+
*/
819
protected $path_executable;
20+
21+
/**
22+
* @var bool
23+
*/
24+
protected $windows;
25+
926
protected $the_command;
10-
protected $windows = false;
1127

1228
protected $formats = ['pdf', 'rtf', 'xls', 'xlsx', 'docx', 'odt', 'ods', 'pptx', 'csv', 'html', 'xhtml', 'xml', 'jrprint'];
13-
protected $resource_directory; //Path to report resource dir or jar file
1429

15-
function __construct($resource_dir = false)
30+
/**
31+
* JasperPHP constructor
32+
*/
33+
public function __construct()
1634
{
17-
$this->path_executable = __DIR__ . '/../JasperStarter/bin'; //Path to executable
18-
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
19-
$this->windows = true;
20-
}
21-
22-
if (!$resource_dir) {
23-
$this->resource_directory = __DIR__ . '/../../../vendor/geekcom/jasperphp/src/JasperStarter/bin';
24-
} else {
25-
if (!file_exists($resource_dir)) {
26-
throw new \Exception('Invalid resource directory.', 1);
27-
}
28-
29-
$this->resource_directory = $resource_dir;
30-
}
35+
$this->executable = 'jasperstarter';
36+
$this->path_executable = __DIR__ . '/../bin/jasperstarter/bin';
37+
$this->windows = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? true : false;
3138
}
3239

3340
public static function __callStatic($method, $parameters)

tests/JasperPHP/JasperPHPTest.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
<?php
2-
class JasperPHPTest extends PHPUnit_Framework_TestCase
2+
namespace JasperPHP;
3+
/**
4+
* Class JasperPHPTest
5+
*
6+
* @author Rafael Queiroz <rafaelfqf@gmail.com>
7+
* @package JasperPHP
8+
*/
9+
class JasperPHPTest extends \PHPUnit_Framework_TestCase
310
{
411

512
/**
6-
*
7-
*/
8-
public function testCompileWithWrongArgs()
9-
{
10-
11-
}
12-
13-
public function testCompile()
13+
* @return JasperPHP
14+
*/
15+
public function testConstructor()
1416
{
15-
17+
$this->assertInstanceOf(JasperPHP::class, new JasperPHP());
1618
}
1719

18-
}
20+
}

0 commit comments

Comments
 (0)