kigkonsult/keyvaluemgr

PHP class manage collection of key/value pair data like system config etc

Fund package maintenance!
Other

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

This package is auto-updated.

Last update: 2024-04-28 20:27:17 UTC


README

Manages collection of key/value pairs like system config etc

USAGE
<?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 )
Methods

KeyValueMgr::__construct( [ configDataArray ] )

  • configDataArray array

KeyValueMgr::factory( [ configDataArray ] )

  • configDataArray array
  • static
  • Return static

KeyValueMgr::singleton( [ configDataArray ] )

  • configDataArray array
  • static
  • Return singleton KeyValueMgr

KeyValueMgr::exists( key )

  • key mixed
  • Return bool true on found

KeyValueMgr::exists( key, true )

  • key mixed
  • true bool true
  • Return bool true on found and value NOT is null, '' or []

KeyValueMgr::get()

  • Return array *( key => value )

KeyValueMgr::get( key )

  • key mixed
  • Return value for key, false on not found

KeyValueMgr::getKeys()

  • Return array *( key )

KeyValueMgr::set( key, value )

  • Insert key/value-pair (overwrite if key exists)
  • key string|int
  • value mixed
  • Return static

KeyValueMgr::set( key, value, true )

  • Insert key/value-pair if key is NOT set
  • key string|int
  • value mixed
  • true bool true
  • Return static

KeyValueMgr::set( configDataArray )

  • Insert array key/value-pairs (overwrite if key exists)
  • configDataArray array *( key => value )
  • Return static

KeyValueMgr::set( configDataArray, null, true )

  • Insert array key/value-pairs where key NOT exists
  • configDataArray array *( key => value )
  • true bool true
  • Return static

KeyValueMgr::remove( key )

  • Unset key/value pair
  • key string|int
  • Return static

KeyValueMgr::remove( keyArr )

  • Unset key/value pairs
  • keyArr array *( key )
  • Return static

KeyValueMgr::remove( keyToKeep, true )

  • Unset all OTHER key/value-pairs
  • keyToKeep string|int
  • true bool true
  • Return static

KeyValueMgr::remove( keyArrToKeep, true )

  • Unset all OTHER key/value-pairs
  • keyArrToKeep array *( key )
  • true bool true
  • Return static

KeyValueMgr::toString()

  • Return nice edited string content output
Sponsorship

Donation using paypal.me/kigkonsult are appreciated. For invoice, please e-mail.

INSTALL
composer require kigkonsult\keyvaluemgr:dev-master

Composer, in your composer.json:

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

KeyValueMgr 1.8 require PHP 8.0, 1.6 7.4, 1.4.1 7.0

Composer, acquire access

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

Otherwise , download and acquire..

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

For support go to github.com KeyValueMgr

License

This project is licensed under the LGPLv3 License.