46 lines
771 B
PHP
Raw Normal View History

2011-09-04 18:33:26 +02:00
<?php
2013-09-24 14:07:04 +02:00
namespace DesignPatterns\Registry;
2011-09-04 18:33:26 +02:00
/**
2013-09-24 14:07:04 +02:00
* class Registry
2011-09-04 18:33:26 +02:00
*/
abstract class Registry
{
const LOGGER = 'logger';
2013-09-13 12:00:39 +02:00
/**
* @var array
*/
protected static $storedValues = array();
2011-09-04 18:33:26 +02:00
/**
2013-09-13 12:00:39 +02:00
* sets a value
*
2011-09-04 18:33:26 +02:00
* @param string $key
2013-09-13 12:00:39 +02:00
* @param mixed $value
*
* @static
2011-09-04 18:33:26 +02:00
* @return void
*/
public static function set($key, $value)
{
2013-09-13 12:00:39 +02:00
self::$storedValues[$key] = $value;
2011-09-04 18:33:26 +02:00
}
/**
2013-09-13 12:00:39 +02:00
* gets a value from the registry
*
2011-09-04 18:33:26 +02:00
* @param string $key
2013-09-13 12:00:39 +02:00
*
* @static
2011-09-04 18:33:26 +02:00
* @return mixed
*/
public static function get($key)
{
2013-09-13 12:00:39 +02:00
return self::$storedValues[$key];
2011-09-04 18:33:26 +02:00
}
// typically there would be methods to check if a key has already been registered and so on ...
}