48 lines
799 B
PHP
Raw Normal View History

2011-09-04 18:33:26 +02:00
<?php
namespace DesignPatterns\Structural\Registry;
2011-09-04 18:33:26 +02:00
/**
2015-12-21 07:28:20 -05: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
/**
2015-12-21 07:28:20 -05:00
* sets a value.
2013-09-13 12:00:39 +02:00
*
2011-09-04 18:33:26 +02:00
* @param string $key
2013-09-13 12:00:39 +02:00
* @param mixed $value
*
* @static
2015-12-21 07:28:20 -05:00
*
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
}
/**
2015-12-21 07:28:20 -05:00
* gets a value from the registry.
2013-09-13 12:00:39 +02:00
*
2011-09-04 18:33:26 +02:00
* @param string $key
2013-09-13 12:00:39 +02:00
*
* @static
2015-12-21 07:28:20 -05:00
*
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 ...
}