Passed
Branch v1.6.0 (c77ef3)
by Wanderson
01:54
created

View::validateFile()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Win\Views;
4
5
use Win\Application;
6
use Win\Common\Template;
7
use Win\HttpException;
8
9
/**
10
 * View
11
 *
12
 * Responsável por criar o visual da página
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, $controller->layout);
26
27
		if (!$this->exists()) {
28
			throw new HttpException("View '{$this->file}' not found", 404);
29
		}
30
	}
31
}
32