grifix/array-wrapper

This package is abandoned and no longer maintained. No replacement package was suggested.

Grifix Array Wrapper

3.0.0 2023-05-15 14:29 UTC

This package is auto-updated.

Last update: 2023-07-26 07:01:57 UTC


README

Usage:

$wrapped = \Grifix\ArrayWrapper\ArrayWrapper::create([
    'name' => 'Joe',
    'address' => [
        'city' => 'London'
    ],
    'tasks' => [
        'wash car',
        'buy food'
    ]      
])

$wrapped->getElement('address');// returns ['city' => 'London']
$wrapped->getElement('address.city'); // 'London' 
$wrapped->getElement('tasks.1'); //buy food
$wrapped->hasElement('tasks.1'); //true
$wrapped->hasElement('tasks.3'); //false
$wrapped->isAssociative(); //true
$wrapped->setElement('address.country', 'Uk');
$wrapped->addElement('tasks', 'clean the apartment');
$wrapped->getFirstElement(); //returns "Joe"
$wrapped->getLastElement(); //returns tasks array
$wrapped->removeElement('address.city');