[code]
<?php

/**
 * static factory for the global singletons
 *
 * @version 1.0
 * @author  Iltar van der Berg
 * @package Berg_Framework
 * @license Free to use if all comments remain intact
 */
class Berg_Globals
{
	/**
	 * factory access for Berg_Globals_Post
	 *
	 * @param string|int $key
	 * @return string|int
	 */
	static public function post($key)
	{
		return Berg_Globals_Post::instance()->{$key};
	}
	
	/**
	 * factory access for Berg_Globals_Get
	 *
	 * @param string|int $key
	 * @return string|int
	 */
	static public function get($key)
	{
		return Berg_Globals_Get::instance()->{$key};
	}
}

/**
 * post singleton class
 * 
 * @version 1.0
 * @author  Iltar van der Berg
 * @package Berg_Framework
 * @license Free to use if all comments remain intact
 */
final class Berg_Globals_Post
{
	/**
	 * instanceof self
	 *
	 * @var Berg_Globals_Post object
	 */
	static protected $_instance = null;
	
	/**
	 * array containing post vars
	 *
	 * @var array
	 */
	static protected $_post = array();
	
	/**
	 * prevent direct access
	 *
	 */
	private function __construct()
	{
		
	}
	
	/**
	 * prevent cloning
	 *
	 */
	private function __clone()
	{
		
	}
	
	/**
	 * create an instance of self
	 *
	 * @return Berg_Globals_Post
	 */
	static public function instance()
	{
		if(!(self::$_instance instanceof self)) {
			self::$_instance = new self();
			self::$_post = $_POST;
		}
		return self::$_instance;
	}
	
	/**
	 * magic method for obtaining post value
	 *
	 * @param string|int $key
	 * @return string
	 */
	public function __get($key)
	{
		return isset(self::$_post[$key]) ? self::$_post[$key] : '';
	}
}

/**
 * get singleton class
 * 
 * @version 1.0
 * @author  Iltar van der Berg
 * @package Berg_Framework
 * @license Free to use if all comments remain intact
 */
final class Berg_Globals_Get
{
	/**
	 * instanceof self
	 *
	 * @var Berg_Globals_Get object
	 */
	static protected $_instance = null;
	
	/**
	 * array containing post vars
	 *
	 * @var array
	 */
	static protected $_get = array();
	
	/**
	 * prevent direct access
	 *
	 */
	private function __construct()
	{
		
	}
	
	/**
	 * prevent cloning
	 *
	 */
	private function __clone()
	{
		
	}
	
	/**
	 * create an instance of self
	 *
	 * @return Berg_Globals_Get
	 */
	static public function instance()
	{
		if(!(self::$_instance instanceof self)) {
			self::$_instance = new self();
			self::$_get = $_GET;
		}
		return self::$_instance;
	}
	
	/**
	 * magic method for obtaining post value
	 *
	 * @param string|int $key
	 * @return string
	 */
	public function __get($key)
	{
		return isset(self::$_get[$key]) ? self::$_get[$key] : '';
	}
}

?>