Skip to content

petrgrishin/array-access

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

array-access

Travis CI Coverage Status

PHP multi array access

Installation

Add a dependency to your project's composer.json file if you use Composer to manage the dependencies of your project:

{
    "require": {
        "petrgrishin/array-access": "~1.0"
    }
}

Usage examples

Basic usage array-access objects

use \PetrGrishin\ArrayAccess\ArrayAccess;

$arrayParams = array(
    'a' => array(
        'b' => 10,
    )
);
$params = ArrayAccess::create($arrayParams);
$value = $params->getValue('a.b');
$params
    ->setValue('a.b', 20)
    ->setValue('a.c', 30);
$params->remove('a.b');
$resultArrayParams = $params->getArray();

Example of usage in Yii2 behavior

https://github.com/petrgrishin/yii2-array-field