<?php



class BaseObject {



	private $intProps = [];

	protected $dataModel = false;



	public function __construct($model = false) {

		if ($model) {

			$this->dataModel = new $model();

		}

	}



	protected function model() {

		return $this->dataModel;

	}



	protected function props($data = false) {

		if (is_array($data)) {

			foreach ($data as $key => $value) {

				$this->setProp($key, $value);

			}

			return $data;

		} elseif ($data === false) {

			return $this->intProps;

		} else {

			echo "<pre>ERRPROPS: "; var_dump($data); echo "</pre>";

		}

		return false;

	}



	public function prop($key, $value = null) {

		if (is_null($value)) {

			if (is_array($key)) {

				return $this->getProp($key[0])[$key[1]] ?? false;

			} else {

				return $this->getProp($key);

			}

		} else {

			return $this->setProp($key, $value);

		}

	}



	public function hasProp($key) {

		if (is_array($key)) {

			return isset($this->intProps[$key[0]][$key[1]]);

		} else {

			return isset($this->intProps[$key]);

		}

	}



	public function isProp($key, $value) {

		return $this->hasProp($key) && $this->intProps[$key] === $value;

	}



	private function getProp($key, $default = false) {

		return $this->hasProp($key) ? $this->intProps[$key] : $default;

	}



	private function setProp($key, $value) {

		return $this->intProps[$key] = $value;

	}



	public function isLoaded($value = null) {

		if (is_null($value)) {

			return $this->prop("loaded");

		} else {

			$this->prop("loaded", $value);

		}

	}



}