Passed
Push — develop ( 8c3394...9d4761 )
by Mykola
08:36
created

Application   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 10
c 0
b 0
f 0
dl 0
loc 24
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 15 2
A set() 0 3 1
1
<?php
2
3
/* 	Sunrise CMS - Open source CMS for widespread use.
4
    Copyright (c) 2019 Mykola Burakov ([email protected])
5
6
    See SOURCE.txt for other and additional information.
7
8
    This file is part of Sunrise CMS.
9
10
    This program is free software: you can redistribute it and/or modify
11
    it under the terms of the GNU General Public License as published by
12
    the Free Software Foundation, either version 3 of the License, or
13
    (at your option) any later version.
14
15
    This program is distributed in the hope that it will be useful,
16
    but WITHOUT ANY WARRANTY; without even the implied warranty of
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
    GNU General Public License for more details.
19
20
    You should have received a copy of the GNU General Public License
21
    along with this program. If not, see <http://www.gnu.org/licenses/>. */
22
23
namespace Sunrise\Engine\Adaptor\Template;
24
25
final class Application
26
{
27
    private $data = array();
28
29
    public function set($key, $value)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
30
    {
31
        $this->data[$key] = $value;
32
    }
33
34
    public function render($template)
35
    {
36
        $file = $_SERVER['DOCUMENT_ROOT'] . '/application/view/' . $template . '.html';
37
38
        if (is_file($file)) {
39
            extract($this->data);
40
41
            ob_start();
42
43
            require($file);
44
45
            return ob_get_clean();
46
        }
47
48
        trigger_error('Error: Could not load template ' . $file . '!');
49
    }
50
}
51