Completed
Push — 186-data ( 572d68...d14d7f )
by
unknown
10:34
created

FileSystemRenderTemplate::renderTemplate()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 10
nc 3
nop 2
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace League\Plates\RenderTemplate;
4
5
use League\Plates;
6
use Throwable;
7
use Exception;
8
9
final class FileSystemRenderTemplate implements Plates\RenderTemplate
10
{
11
    private $include;
12
13
    public function __construct($include = null) {
14
        $this->include = $include ?: Plates\Template\phpInclude();
15
    }
16
17
    public function renderTemplate(Plates\Template $template, Plates\RenderTemplate $rt = null) {
18
        $path = Plates\Template\getPath($template);
19
20
        try {
21
            return ($this->include)($path, $template->data);
22
        } catch (Exception $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
23
24
        } catch (Throwable $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
25
26
        }
27
28
        throw new Plates\Exception\PlatesException(
29
            'An exception occurred while rendering Template ' . $template->name . '.',
30
            0,
31
            $e
32
        );
33
    }
34
}
35