ComplexFileBasedTemplate::__get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/**
3
 * @author stev leibelt <[email protected]>
4
 * @since 2015-10-03
5
 */
6
namespace Net\Bazzline\Component\Template;
7
8
use RuntimeException;
9
10
class ComplexFileBasedTemplate extends AbstractFileBasedTemplate
11
{
12
    /**
13
     * enables support for $this->foo
14
     * @param string $name
15
     * @return null|mixed
16
     */
17
    public function __get($name)
18
    {
19
        return $this->getValueByKeyOrNull($name);
20
    }
21
22
    /**
23
     * @return string
24
     * @throws RuntimeException
25
     */
26
    public function render()
27
    {
28
        $filePath   = $this->getFilePath();
29
        $variables  = $this->getVariables();
30
31
        $this->throwRuntimeExceptionIfFilePathIsInvalid($filePath);
32
33
        //enable support for $foo
34
        extract($variables, EXTR_SKIP);
35
36
        ob_start();
37
        include $filePath;
38
        $content = ob_get_clean();
39
40
        return $content;
41
    }
42
}
43