kigkonsult/keyvaluemgr

PHP类,用于管理键/值对数据集合,如系统配置等

资助包维护!
其他

v1.8 2021-10-28 15:10 UTC

This package is auto-updated.

Last update: 2024-08-28 21:06:27 UTC


README

管理键/值对集合,如系统配置等

用法
<?php
namespace Kigkonsult\KeyValueMgr;

// set up some config

$key   = 'key';
$value = 'value;
$configDataArray = [ $key => $value ];

// set up KeyValueMgr

$cfgMgr = new KeyValueMgr();
$cfgMgr->set( $configDataArray );
$cfgMgr->set( 'key2', 'value2' );

// usage exists / get / remove

if( $cfgMgr->exists( $key ) {
   $value = $cfgMgr->get( $key );
}
$cfgMgr->remove( $key )
方法

KeyValueMgr::__construct( [ configDataArray ] )

  • configDataArray 数组

KeyValueMgr::factory( [ configDataArray ] )

  • configDataArray 数组
  • 静态
  • 返回静态

KeyValueMgr::singleton( [ configDataArray ] )

  • configDataArray 数组
  • 静态
  • 返回单例KeyValueMgr

KeyValueMgr::exists( key )

  • key 混合类型
  • 找到时返回bool true

KeyValueMgr::exists( key, true )

  • key 混合类型
  • true 布尔类型 true
  • 找到时返回bool true,且值不为 null, '' 或 []

KeyValueMgr::get()

  • 返回数组 *( key => value )

KeyValueMgr::get( key )

  • key 混合类型
  • 返回键对应的值,未找到时返回false

KeyValueMgr::getKeys()

  • 返回数组 *( key )

KeyValueMgr::set( key, value )

  • 插入键/值对(如果键存在则覆盖)
  • key 字符串|int
  • value 混合类型
  • 返回静态

KeyValueMgr::set( key, value, true )

  • 如果键未设置,则插入键/值对
  • key 字符串|int
  • value 混合类型
  • true 布尔类型 true
  • 返回静态

KeyValueMgr::set( configDataArray )

  • 插入数组键/值对(如果键存在则覆盖)
  • configDataArray 数组 *( key => value )
  • 返回静态

KeyValueMgr::set( configDataArray, null, true )

  • 插入数组键/值对,其中键不存在
  • configDataArray 数组 *( key => value )
  • true 布尔类型 true
  • 返回静态

KeyValueMgr::remove( key )

  • 取消设置键/值对
  • key 字符串|int
  • 返回静态

KeyValueMgr::remove( keyArr )

  • 取消设置键/值对
  • keyArr 数组 *( key )
  • 返回静态

KeyValueMgr::remove( keyToKeep, true )

  • 取消设置所有其他键/值对
  • keyToKeep 字符串|int
  • true 布尔类型 true
  • 返回静态

KeyValueMgr::remove( keyArrToKeep, true )

  • 取消设置所有其他键/值对
  • keyArrToKeep 数组 *( key )
  • true 布尔类型 true
  • 返回静态

KeyValueMgr::toString()

  • 返回格式良好的字符串内容输出
赞助

使用 paypal.me/kigkonsult 进行捐款受到赞赏。如有发票,请发送电子邮件

安装
composer require kigkonsult\keyvaluemgr:dev-master

Composer,在您的 composer.json

{
    "require": {
        "kigkonsult\keyvaluemgr": "dev-master"
    }
}

KeyValueMgr 1.8 需要 PHP 8.0,1.6 7.4,1.4.1 7.0

Composer,获取访问权限

use Kigkonsult\KeyValueMgr\KeyValueMgr;
...
include 'vendor/autoload.php';

否则,下载并获取..

use Kigkonsult\KeyValueMgr\KeyValueMgr;
...
include 'pathToSource/kigkonsult/keyvaluemgr/autoload.php';
支持

有关支持,请访问 github.com KeyValueMgr

许可证

本项目采用LGPLv3许可证。