You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While this still works, it should be considered abandoned. Any PR issued will be accepted w/o question. If you want to own this repository, open an issue and contact me.
Data Manager
Simple data manager for nested data, dot notation access, extendability, and container interoperability.
Manager does exactly what you would expect: it manages complex items such as config data, arrays, and closures.
The best way to get started is simply instantiate Michaels\Manager\Manager
$manager = newMichaels\Manager\Manager([
'some' => [
'starting' => [
'data' => 'here (optional)'
]
]
]);
// Note, you may initialize Manager with an array or any instance of Traversable (like Manager itself)/* Basic Usage. All works with dot notation as well */$manager->add('name', 'value');
$manager->add('some.nested.data', 3); // Use dot notation for namespacing or nesting$manager->get('name'); // 'value'$manager->get('doesntexist', 'fallback'); // 'fallback'$manager->get('doesntexist') // throws an ItemNotFoundException with no fallback$manager->getIfHas('doesntexist') // returns a NoItemFoundMessage instead of a script-stopping exception$manager->getAll(); // returns array of all items$manager->all(); // returns array of all items$manager->exists('name'); // true$manager->exists('some.starting.data'); // true$manager->exists('nope'); // false$manager->has('something'); // alias of exist$manager->set('name', 'new-value'); // updates item$manager->remove('some.starting.data');
$manager->isEmpty(); // true or false$manager->toJson(); // returns json of all itemsecho$manager; // returns json string of all items$manager->reset($array); // rebuild with new items$manager->clear(); // empty the manager/* You can also use $manager as an array or in loops */$manager['some']['starting']['data']; // 'here (optional)'//etcforeach ($manageras$item => $value) {
// do whatever your heart desires
}
/* You may also push elements onto an array */$manager->set('a.b', []);
$manager->push('a.b', 'c', 'd', 'e');
$manager->get('a.b'); // ['c', 'd', 'e']/* Finally, you may manage values using magic methods */$manager->some()->starting()->data; // 'here (optional)'$manager->some()->item = 'item'; // sets some.item = 'item'$manager->some()->item()->drop(); // deletes some.item// Note that levels are called as a method with no params. The data is then called, updated, or set as a property.
Advanced Features
See documentation for topics like protecting data, using as an ioc container, loading files, using as an array, defaults, composing, and more.
You may also use the tests under tests/traits to test your integrated functionality. You may have to grab these through cloning the repo. composer usually won't include tests in your require
Contributing
Contributions are welcome and will be fully credited. Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email chrismichaels84@gmail.com instead of using the issue tracker.