<?php
	/**
	* The <strong>Registry</strong> class is reponsible of storing objects, string, integers, etc
	* in one single instance of Registry to be used across the system.
	*
	* @copyright Trusto Tech 2015-2016
	* @author  Taha Sayyad <info@trustotech.com>
	* @package System\Core
	*
	* @method void __set($key, $value) Sets a value and its key in the storage array
	* @method mixed __get($key) Returns the value for a given key
	*/
	class Registry {

		/**
		* @var string Holds an object of the Registry class
		*/
		private static $_instance;

		/**
		* @var array Holds an associative array of boolean values, objects, integers, strings, etc
		*/
		private $_storage;

		/**
		* Check if there is no instance instance of the Registry class and creates it.
		*
		* @return obj Registry class object
		*/
		public static function getInstance() {
			if (!self::$_instance instanceof self)
				self::$_instance = new self;
			return self::$_instance;
		}

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

		final public function __get($key) {
			if (isset($this->_storage[$key]))
				return $this->_storage[$key];
			return false;
		}

	}