Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
6 / 6
View
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
6 / 6
 __construct
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
6 / 6
<?php
namespace Win\Templates;
use Win\Application;
use Win\HttpException;
/**
 * View - Template da Página
 * 
 * Exibe as variáveis públicas do controller
 */
class View extends Template
{
    /**
     * Cria uma View com base no arquivo escolhido
     * @param string $file arquivo da View
     */
    public function __construct($file, $data = [])
    {
        $controller = Application::app()->controller;
        $data = array_merge(get_object_vars($controller), $data);
        parent::__construct($file, $data);
        if (!$this->exists()) {
            throw new HttpException("View '{$this->file}' não encontrada.", 404);
        }
    }
}