PHP single context. Key value store in current context.
18
4
2
Package Data
Maintainer Username: arifmahmudrana
Maintainer Contact: arif_mahmud_rana@hotmail.com (Arif Mahmud Rana)
Package Create Date: 2017-02-05
Package Last Update: 2017-05-13
Language: PHP
License: MIT
Last Refreshed: 2024-04-25 15:11:31
Package Statistics
Total Downloads: 18
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 4
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

PHP Context(Key Value Data Store)

Build Status

This is nothing but a key value store in the current context. You store value & in other places you retrieve value by it's key.

Usage

Step 1: Install Through Composer

composer require arifmahmudrana/context

and that's it.

Examples

Set Value

use ArifMahmudRana\Context\ContextContainer;

ContextContainer::set('user', User::find(1))//Save user Returns true

Get Value

use ArifMahmudRana\Context\ContextContainer;

ContextContainer::get('user')//Get user

Has Value

use ArifMahmudRana\Context\ContextContainer;

ContextContainer::has('user')//Return true

All Value

use ArifMahmudRana\Context\ContextContainer;

ContextContainer::all()//Returns key value ['user' => User Object] default empty array

Remove Value

use ArifMahmudRana\Context\ContextContainer;

ContextContainer::remove('user')//Returns true removes the key

Important

  1. You can't instantiate this class if tried it will throw CannotInstantiateClassExceptions exception
  2. You can use only string as key else it will throw \InvalidArgumentException exception

Tests

To Run the tests

./vendor/bin/phpunit //run phpunit

Contributing

All contributions are welcome, for any bug, issue or merge request please refer to CONTRIBUTING.md

License

Released under the MIT License, see LICENSE.