bcismariu/commons-descendable

There is no license information available for the latest version (v0.1) of this package.

A property accessor helper capable of using dot notation for a mix of arrays and objects

v0.1 2017-07-21 13:27 UTC

This package is auto-updated.

Last update: 2024-11-13 06:32:08 UTC


README

Build Status Latest Stable Version License Total Downloads

A generic dot notation accessor, able to handle a mix of arrays and objects

Installation

composer require bcismariu/commons-descendable:^0.1

Usage

<?php

use Bcismariu\Commons\Descendable\Descendable;

$array = [
    'eyes'  => 'blue',
    'age'   => '27',
    'parents' => [
        'mother'    => 'Jane',
        'father'    => 'Jack'
    ]
];

$descendable = new Descendable($array);

$descendable->get('parents.father', 'John');    // returns 'Jack'
$descendable->get('sister', 'Kate');            // returns 'Kate'

Testing

php vendor/bin/phpunit