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.
composer require arifmahmudrana/context
and that's it.
use ArifMahmudRana\Context\ContextContainer;
ContextContainer::set('user', User::find(1))//Save user Returns true
use ArifMahmudRana\Context\ContextContainer;
ContextContainer::get('user')//Get user
use ArifMahmudRana\Context\ContextContainer;
ContextContainer::has('user')//Return true
use ArifMahmudRana\Context\ContextContainer;
ContextContainer::all()//Returns key value ['user' => User Object] default empty array
use ArifMahmudRana\Context\ContextContainer;
ContextContainer::remove('user')//Returns true removes the key
- You can't instantiate this class if tried it will throw
CannotInstantiateClassExceptions
exception - You can use only string as key else it will throw
\InvalidArgumentException
exception
To Run the tests
./vendor/bin/phpunit //run phpunit
All contributions are welcome, for any bug, issue or merge request please refer to CONTRIBUTING.md
Released under the MIT License, see LICENSE.