PhpView   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 4
c 2
b 1
f 0
lcom 1
cbo 0
dl 0
loc 58
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setTemplate() 0 6 1
A assign() 0 6 1
A render() 0 10 1
A xmlProlog() 0 4 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