<?php
namespace lib\Core;

class View
{
    private $_values = [];
    private $_debug = false;
    public function __construct()
    {
    } //
    final public function setDebug($debug)
    {
        $this->_debug = $debug;
    }
    final public function getDebug()
    {
        return $this->_debug;
    }

    final public function __get($name)
    {
        return $this->_values[$name];
    }
    final public function __set($name, $value)
    {
        $this->_values[$name] = $value;
    }

    public function render($file)
    {
        $viewFileName = sprintf("lib/View/%s", $file);
        $fullPathFile = "./" . $viewFileName . '.php';
        if (!file_exists($fullPathFile)) {
            throw new \Exception(sprintf("%s 파일이 존재하지 않습니다.", $fullPathFile));
        }
        ob_start();
        include $fullPathFile;
        return ob_end_flush();
    }
} //Class
