ComplexFileBasedTemplate   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 33
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __get() 0 4 1
A render() 0 16 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