<?php
namespace Main\GlobalData;

require_once 'Object.php';
use \Main\Object;	

class Data extends Object
{
	// Attributes
	///private static $_instance = new Data(); <-- This doesn't work
	private static $_instance;

	private $_number;
	private $_text;
	private $_dynamicProperties = [];

	// Constructor
	
	private function __construct()
	{
	}
	
	// Methods for properties
	// Getters and Setters

	public static function GetInstance()
	{
		// To access static attribute within class,
		// use the "self" keyword
		// Lazy singleton approach
		if(empty(self::$_instance))
		{
			self::$_instance = new Data();		
		}	
		return self::$_instance; 
	}
	
	public function GetNumber()
	{
		return $this->_number;
	}
	
	public function SetNumber($value)
	{
		$this->_number = $value;
	}
	
	public function GetText()
	{
		return $this->_text;
	}
	
	public function SetText($value)
	{
		$this->_text = $value;
	}	
	
	// Methods
	public function SetProperty($key, $value)
	{
		$this->_dynamicProperties[$key] = $value;
	}
	
	public function GetProperty($key)
	{
		return $this->_dynamicProperties[$key];
	}
}
?>