extphp / data-dot
A property accessor helper capable of using dot notation for a mix of arrays and objects.
Installs: 1 647
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=5.6
Requires (Dev)
- phpunit/phpunit: ^5.0|^6.0|^7.0
This package is auto-updated.
Last update: 2024-10-14 08:06:24 UTC
README
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