Conditions | 3 |
Paths | 3 |
Total Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 0 |
1 | <?php |
||
29 | public function render(string $file, array $data) : void |
||
30 | { |
||
31 | if (!is_readable($file)) { |
||
32 | throw new Exception("Could not find template file: " . $this->template); |
||
|
|||
33 | } |
||
34 | |||
35 | $di = $this->di; |
||
36 | $app = null; |
||
37 | if ($di->has("app")) { |
||
38 | $app = $di->get("app"); |
||
39 | } |
||
40 | extract($data); |
||
41 | require $file; |
||
42 | } |
||
43 | } |
||
44 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: