PHP code example of thinktomorrow / magic-attributes
1. Go to this page and download the library: Download thinktomorrow/magic-attributes 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/ */
use \Thinktomorrow\MagicAttributes\HasMagicAttributes;
class Customer{
use HasMagicAttributes;
}
class Customer{
/* allows for $customer->addressStreet instead of $customer->attr('address.street') */
public function __get($key)
{
return $this->magicAttribute($key);
}
/* with __isset you allow to check if the property exists on this class, e.g. isset($customer->addressStreet) */
public function __isset($key)
{
return false !== $this->magicAttribute($key, false);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.