dbeurive/registry

本软件包包含一个注册表的简单实现。

1.0.0 2016-04-29 14:42 UTC

This package is not auto-updated.

Last update: 2024-09-20 19:24:57 UTC


README

本软件包实现了一个简单的注册表。

安装

通过命令行

composer require dbeurive/tree

从您的 composer.json 文件中

{
    "require": {
        "dbeurive/tree": "1.0.*"
    }
}

API 文档

API 的详细文档可以通过使用 PhpDocumentor 从代码中提取。文件 phpdoc.xml 包含了 PhpDocumentor 所需的配置。要生成 API 文档,只需将当前目录移动到本软件包的根目录,并从这个位置运行 PhpDocumentor

注意

由于所有 PHP 代码都使用了 PhpDoc 注释进行文档说明,您应该能够从您最喜欢的 IDE 中利用自动完成功能。如果您正在使用 Eclipse、NetBeans 或 PhPStorm,您可能不需要查阅生成的 API 文档。

概述

注册条目

$value = 10;
dbeurive\Registry\Registry::register('YourEntry', $value);

注册条目并声明为常量

$value = 10;
dbeurive\Registry\Registry::register('YourEntry', $value, true);

获取已注册条目的值

dbeurive\Registry\Registry::get('YourEntry');

更改已注册条目的值

$newValue = 20;
dbeurive\Registry\Registry::set('YourEntry', $newValue);

测试条目是否已注册

if (dbeurive\Registry\Registry::isRegistered('YourEntry')) { ... }

测试条目是否声明为常量

if (dbeurive\Registry\Registry::isConstant('YourEntry')) { ... }

示例

单元测试是很好的示例。