biera / array-accessor
utils for accessing object's graph with ease
Installs: 24 730
Dependents: 2
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=7.4
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-11-12 00:56:31 UTC
README
Tiny lib which lets you access object graph with ease.
usage
Just use Biera\ArrayAccessor
trait. Don't forget to make your class implements \ArrayAcccess
interface.
use ArrayAccess; use Biera\ArrayAccessor; class User implements ArrayAccess { use ArrayAccessor; private Address $address; ... public function getAddress(): Address { return $this->address; } ... } class Address implements ArrayAccess { use ArrayAccessor; private string $street; private string $zipCode; ... public function getZipCode(): string { return $this->zipCode; } ... } ... /** @var User $user */ assert($user['address']['zipCode'] == $user->getAddress()->getZipCode());
installation
The lib is distributed as composer package.
composer req biera/array-accessor