配置管理
namespace ginkgo;
class Config {
// 属性
public static $config;
public static $range = array();
public static $count = 1;
private static $init;
// 方法
public static init()
public static range( [ string $range ] ) : array
public static add( mixed $name [, mixed $value [, string $range ]] )
public static set( mixed $name [, mixed $value [, string $range ]] )
public static get( [ string $name [, string $range ]] ) : mixed
public static delete( [ string $name [, string $range ]] )
public static count() : int
public static load( string $path [, string $name [, string $range ]] ) : mixed
public static write( string $path [, mixed $value ] ) : int
private static loadSys()
private static rangeProcess( [ string $range ] ) : array
}
- | 权限 | 类型 | 描述 |
---|---|---|---|
属性 | - | - | - |
$config |
public | array static | 配置值 |
$range |
public | string static | 作用域 |
$count |
public | int static | 载入配置文件计数 |
$init |
private | bool static | 是否初始化 |
方法 | - | - | - |
init() | public | static | 初始化 |
range() | public | static | 设置、获取作用域 |
add() | public | static | 添加配置(不覆盖) |
set() | public | static | 设置配置(覆盖) |
get() | public | static | 读取配置 |
delete() | public | static | 删除配置 |
count() | public | static | 载入配置文件计数 |
load() | public | static | 载入配置文件 |
write() | public | static | 写入配置文件 |
loadSys() | private | static | 载入系统配置 |
rangeProcess() | private | static | 作用域处理 |
init()
初始化public static function init()
参数
返回
range()
设置、获取作用域public static function range( [ string $range ] ) : array
参数
range
作用域,支持二级作用域,两级作用域之间用 . 隔开,如此参数为空,则返回作用域返回
add()
添加配置(不覆盖)public static function add( mixed $name [, mixed $value [, string $range ]] )
参数
name
名称
支持两种类型:为字符串时表示配置名,为数组时表示批量添加
value
值
当 name
为字符串时为必须,当 name
为数组时自动忽略。
range
作用域
返回
set()
设置配置(覆盖)public static function set( mixed $name [, mixed $value [, string $range ]] )
参数
name
名称
支持两种类型:为字符串时表示配置名,为数组时表示批量设置
value
值
当 name
为字符串时为必须,当 name
为数组时自动忽略。
range
作用域
返回
get()
读取配置public static function get( [ string $name [, string $range ]] ) : mixed
参数
name
名称range
作用域返回
delete()
删除配置public static function delete( [ string $name [, string $range ]] )
参数
name
名称range
作用域返回
count()
载入配置文件计数public static function count() : int
参数
返回
load()
载入配置文件public static function load( string $path [, string $name [, string $range ]] ) : mixed
参数
path
配置文件路径name
名称range
作用域返回
write()
载入配置文件public static function write( string $path [, mixed $value ] ) : int
参数
path
配置文件路径value
值
支持两种类型:字符串、数组
返回
loadSys()
载入系统配置private static function loadSys()
参数
返回
rangeProcess()
作用域处理private static function rangeProcess( [ string $range ] ) : array
参数
range
作用域返回