PhpView::setTemplate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace N98\View;
4
5
class PhpView implements View
6
{
7
    /**
8
     * @var array
9
     */
10
    protected $vars = array();
11
12
    /**
13
     * @var
14
     */
15
    protected $template;
16
17
    /**
18
     * @param string $template
19
     * @return PhpView
20
     */
21
    public function setTemplate($template)
22
    {
23
        $this->template = $template;
24
25
        return $this;
26
    }
27
28
    /**
29
     * @param string $key
30
     * @param mixed $value
31
     *
32
     * @return PhpView
33
     */
34
    public function assign($key, $value)
35
    {
36
        $this->vars[$key] = $value;
37
38
        return $this;
39
    }
40
41
    /**
42
     * @return string
43
     */
44
    public function render()
45
    {
46
        extract($this->vars);
47
        ob_start();
48
        include $this->template;
49
        $content = ob_get_contents();
50
        ob_end_clean();
51
52
        return $content;
53
    }
54
55
    /**
56
     * @return string
57
     */
58
    protected function xmlProlog()
59
    {
60
        return '<?xml version="1.0"?>' . "\n";
61
    }
62
}
63