| Conditions | 3 |
| Paths | 3 |
| Total Lines | 29 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 56 | 2 | protected function renderFile(string $file): string |
|
| 57 | { |
||
| 58 | 2 | if (!is_readable($file)) { |
|
| 59 | 1 | throw new \InvalidArgumentException(sprintf('File "%s" is nonexistent (Working directory: %s)', $file, getcwd())); |
|
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Start the output buffer and require file |
||
| 64 | */ |
||
| 65 | 1 | ob_start(); |
|
| 66 | |||
| 67 | /** |
||
| 68 | * Prepare set variables for the view |
||
| 69 | * |
||
| 70 | * @todo Helpers, `$this->loadHelpers();` |
||
| 71 | */ |
||
| 72 | 1 | foreach ($this->variables as $variable => $value) { |
|
| 73 | 1 | $$variable = $value; |
|
| 74 | } |
||
| 75 | |||
| 76 | 1 | require $file; |
|
| 77 | |||
| 78 | /** |
||
| 79 | * Clean the output buffer and return |
||
| 80 | */ |
||
| 81 | 1 | $output = ob_get_clean(); |
|
| 82 | |||
| 83 | 1 | return $output; |
|
| 84 | } |
||
| 85 | } |
||
| 86 |