| Conditions | 2 |
| Paths | 2 |
| Total Lines | 21 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | public function render(ViewInterface $view) |
||
| 18 | { |
||
| 19 | $templateName = $view->getTemplate(); |
||
| 20 | $templatePath = sprintf('%s/%s.php', $this->templatePath, $template); |
||
| 21 | |||
| 22 | if (!file_exists($template)) { |
||
| 23 | throw new TemplateNotFoundException(sprintf( |
||
| 24 | 'Template "%s" not found at "%s"', |
||
| 25 | $templateName, $templatePath |
||
| 26 | )); |
||
| 27 | } |
||
| 28 | |||
| 29 | $output = function () use ($view) { |
||
| 30 | ob_start(); |
||
| 31 | $renderer = $this; |
||
| 32 | require_once($template); |
||
| 33 | return ob_get_clean(); |
||
| 34 | }; |
||
| 35 | |||
| 36 | return $output; |
||
| 37 | } |
||
| 38 | } |
||
| 39 |
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: