PHP code example of biera / array-accessor

1. Go to this page and download the library: Download biera/array-accessor library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

biera / array-accessor example snippets


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());
shell 
composer req biera/array-accessor