PHP Key Value Pair Object: Manage collections of key-value pairs

Recommend this page to a friend!
  Info   View files Documentation   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2021-01-14 (1 month ago) RSS 2.0 feedNot yet rated by the usersTotal: 67 All time: 9,791 This week: 338Up
Version License PHP version Categories
keyvaluemgr 1.0.0GNU Lesser Genera...5PHP 5, Data types
Description Author

This class can manage collections of key-value pairs.

It can store a list of named keys that will be associated to values.

The list can be initialized setting the keys to the respective values, one by one or passing an array with many values to initialize the key-value pair list at once.

The class can also perform other types of key-value pair list manipulation like:

- Check if a value exists with a given key
- Get the value of a key
- Remove a key from a list

Picture of Kjell-Inge Gustafsson
  Performance   Level  
Name: Kjell-Inge Gustafsson <contact>
Classes: 14 packages by
Country: Sweden Sweden
Innovation award
Innovation award
Nominee: 5x

Details

KeyValueMgr

> 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

* configDataArray array 

  • configDataArray array
  • static
  • return KeyValueMgr
* configDataArray  array
* static
* return singleton KeyValueMgr
<br><br>


  • return bool true on found
* return bool true on found and value NOT is ```null, '' or []```
<br><br>

  • return array *( key => value )
* return value for key, false on not found

  • return array *( key ) <br><br>
* insert key/value-pair (overwrite if key exists)
* key    string|int 
* value  mixed 
* return KeyValueMgr

  • insert key/value-pair if key is NOT set
  • key string|int
  • value mixed
  • return KeyValueMgr
* insert array key/value-pairs (overwrite if key exists)
configDataArray  array( key => value )
* return KeyValueMgr

  • insert array key/value-pairs where key NOT exists
  • configDataArray array *( key => value )
  • return KeyValueMgr <br><br>
* unset key/value pair
* key    string|int
* return KeyValueMgr

  • unset key/value pairs
  • keyArr array *( key )
  • return KeyValueMgr
* unset all OTHER key/value-pairs 
* keyToKeep  string|int 
* return KeyValueMgr

  • unset all OTHER key/value-pairs
  • keyArrToKeep array *( key )
  • return KeyValueMgr <br><br>
* Return nice edited string content output


###### Sponsorship

Donation using <a href="https://paypal.me/kigkonsult?locale.x=en_US" rel="nofollow">paypal.me/kigkonsult</a> are appreciated. 
For invoice, <a href="mailto:ical@kigkonsult.se">please e-mail</a>.

###### INSTALL

composer require kigkonsult\keyvaluemgr:dev-master


Composer, in your `composer.json`:

{

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

}


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


[Composer]:https://getcomposer.org/
[github.com KeyValueMgr]:https://github.com/iCalcreator/keyvaluemgr
  Files folder image Files  
File Role Description
Files folder imagesrc (1 file)
Files folder imagetest (1 file)
Accessible without login Plain text file autoload.php Aux. Auxiliary script
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENCE Lic. License text
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
  Plain text file KeyValueMgr.php Class Class source

  Files folder image Files  /  test  
File Role Description
  Plain text file KeyValueMgrTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:67
This week:0
All time:9,791
This week:338Up

For more information send a message to info at phpclasses dot org.