Skip to content

When the `array` structure needs to be more like an `object` for a while.

License

Notifications You must be signed in to change notification settings

ondrejmirtes/array-wrapper

Repository files navigation

Array wrapper

When the array structure needs to be more like an object for a while.

Requirements

Installation

The best way to install zeleznypa/array-wrapper is using Composer:

composer require zeleznypa/array-wrapper

Example: usage of ArrayWrapper

$array = ['key' => 'value'];
$arrayWrapper = ArrayWrapper::create($array);

// Check array key exists
isset($arrayWrapper['key']);
isset($arrayWrapper->key);
$arrayWrapper->isKey();
$arrayWrapper->hasKey();
$arrayWrapper->offsetExists('key');

// Get array value by key
echo $arrayWrapper['key'];
echo $arrayWrapper->key;
echo $arrayWrapper->getKey();
echo $arrayWrapper->offsetGet('key');

// Set array value by key
$arrayWrapper['key'] = 'value';
$arrayWrapper->key = 'value';
$arrayWrapper->setKey('value');
$arrayWrapper->offsetSet('key', 'value');

// Unset array value by key
unset($arrayWrapper['key']);
unset($arrayWrapper->key);
$arrayWrapper->unsetKey();
$arrayWrapper->offsetUnset('key');

About

When the `array` structure needs to be more like an `object` for a while.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages