добавлен класс реестра
This commit is contained in:
1 parent
87c94eb837
commit
75d8c7380f
1 file changed
+43
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* Класс реестра
|
||||
*/
|
||||
|
||||
namespace Core\Helpers;
|
||||
|
||||
class Registry
|
||||
{
|
||||
private static $_storage = [];
|
||||
|
||||
/**
|
||||
* Установка значения
|
||||
*/
|
||||
public static function set($key, $value)
|
||||
{
|
||||
return self::$_storage[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получение значения
|
||||
*/
|
||||
public static function get($key, $default = null)
|
||||
{
|
||||
return (isset(self::$_storage[$key])) ? self::$_storage[$key] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Удаление
|
||||
*/
|
||||
public static function del($key): void
|
||||
{
|
||||
unset(self::$_storage[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Очистка
|
||||
*/
|
||||
public static function flush(): void
|
||||
{
|
||||
self::$_storage = [];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user