Completed
Push — master ( 0db593...5f0535 )
by Jean-Christophe
01:58
created

MicroTemplateEngine   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 29
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A render() 0 13 3
A getBlockNames() 0 3 1
1
<?php
2
3
namespace Ubiquity\views\engine\micro;
4
5
use Ubiquity\views\engine\TemplateEngine;
6
use Ubiquity\controllers\Startup;
7
8
class MicroTemplateEngine extends TemplateEngine {
9
	private $viewsFolder;
10
11
	public function __construct() {
12
		$this->viewsFolder=ROOT . DS . "views/";
13
	}
14
15
	/*
16
	 * (non-PHPdoc)
17
	 * @see TemplateEngine::render()
18
	 */
19
	public function render($viewName, $pData, $asString) {
20
		$config=Startup::getConfig();
21
		$fileName=$this->viewsFolder . $viewName;
22
		if (is_array($pData)) {
23
			extract($pData);
24
		}
25
		$tpl=new TemplateParser($fileName);
26
		$content=eval('?>' . $tpl->__toString());
27
		if ($asString)
28
			return $content;
29
		else
30
			echo $content;
31
	}
32
	public function getBlockNames($templateName) {
33
		return [];
34
	}
35
36
}
37