<?php

namespace app\models;
if(!defined('ACCESS_CONTROL')) {header($_SERVER['SERVER_PROTOCOL']. ' 404'); exit('404 not found');}
use lib\Core;

abstract class Model {
    protected $_data    =   [];
    protected $_errors  =   [];

    protected $core;
    function __construct() {
        $this->core = Core::getInstance();
    }

    public abstract function is_valid();


    public function __get($key)
    {
        return isset($this->_data[$key]) ? $this->_data[$key] : null;
    }

    public function set(array $data)
    {
        foreach($data as $k=>$v)
            $this->_data[$k] = $v;
    }

    public function __set($key, $value)
    {
        $this->_data[$key] = $value;
    }

    /**
     * @return mixed
     */
    public function getErrors()
    {
        return $this->_errors;
    }

} 