extphp/data-dot

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

v0.1 2018-11-13 17:26 UTC

This package is auto-updated.

Last update: 2024-11-14 08:18:33 UTC


README

Build Status Latest Stable Version License Total Downloads

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

Usage

<?php

use ExtPHP\DataDot\Dot;

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

$dot = new Dot($data);

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

Testing

php vendor/bin/phpunit