Passed
Pull Request — master (#22)
by Wanderson
02:51
created

View   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 15
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
1
<?php
2
3
namespace Win\Templates;
4
5
use Win\Application;
6
use Win\HttpException;
7
8
/**
9
 * View
10
 *
11
 * Responsável por criar o visual da página,
12
 * Extraindo as variáveis publicas do controller
13
 */
14
class View extends Template
15
{
16
	/**
17
	 * Cria uma View com base no arquivo escolhido
18
	 * @param string $file arquivo da View
19
	 */
20
	public function __construct($file, $data = [])
21
	{
22
		Application::app()->view = $this;
23
		$controller = Application::app()->controller;
24
		$data = array_merge(get_object_vars($controller), $data);
25
		parent::__construct($file, $data);
26
27
		if (!$this->exists()) {
28
			throw new HttpException("View '{$this->file}' not found", 404);
29
		}
30
	}
31
}
32