@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace HnrAzevedo\Viewer; |
4 | 4 | |
5 | -class Viewer{ |
|
5 | +class Viewer { |
|
6 | 6 | use HelperTrait, CheckTrait; |
7 | 7 | |
8 | 8 | private static $instance = null; |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | public static function getInstance(string $path): Viewer |
17 | 17 | { |
18 | - if(is_null(self::$instance)){ |
|
18 | + if (is_null(self::$instance)) { |
|
19 | 19 | self::$instance = new self(); |
20 | 20 | } |
21 | 21 | self::$instance->path = $path; |
@@ -29,13 +29,13 @@ discard block |
||
29 | 29 | |
30 | 30 | public function render(string $file, array $data = [], bool $return = false): string |
31 | 31 | { |
32 | - if(!headers_sent()){ |
|
32 | + if (!headers_sent()) { |
|
33 | 33 | header('Content-Type: text/html; charset=utf-8'); |
34 | 34 | } |
35 | 35 | |
36 | 36 | $this->check_viewExist($file); |
37 | 37 | |
38 | - $buffer = $this->getOB($this->path . DIRECTORY_SEPARATOR . $file . '.view.php', $data); |
|
38 | + $buffer = $this->getOB($this->path.DIRECTORY_SEPARATOR.$file.'.view.php', $data); |
|
39 | 39 | |
40 | 40 | $buffer = $this->getVars($buffer); |
41 | 41 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | $this->saveData(); |
45 | 45 | |
46 | - if(!$return){ |
|
46 | + if (!$return) { |
|
47 | 47 | echo $buffer; |
48 | 48 | return ''; |
49 | 49 | } |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | public function include(string $file): void |
55 | 55 | { |
56 | 56 | $buffer = ''; |
57 | - try{ |
|
57 | + try { |
|
58 | 58 | $buffer = $this->getOB($this->path.$file.'.tpl.php'); |
59 | 59 | $buffer = $this->getVars($buffer); |
60 | - }catch(\Exception $er){ |
|
60 | + }catch (\Exception $er) { |
|
61 | 61 | $buffer = "<div class='view error'>Component error: {$er->getMessage()}</div>"; |
62 | 62 | } |
63 | 63 | echo $buffer; |