PHP code example of alexanevsky / getter-setter-accessor-bundle
1. Go to this page and download the library: Download alexanevsky/getter-setter-accessor-bundle 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/ */
alexanevsky / getter-setter-accessor-bundle example snippets
use Alexanevsky\GetterSetterAccessorBundle\GetterSetterAccessor;
public function __construct(
private GetterSetterAccessor $getterSetterAccessor
) {}
$objectAccessor = $this->getterSetterAccessor->createAccessor($objectAccessor);
echo $objectAccessor->getValue('userName');
echo $objectAccessor->getValue('user_name');
if ($objectAccessor->hasGetter('userName')) {
echo $objectAccessor->getValue('userName');
}
echo $objectAccessor->SetValue('userName', 'John Doe');
echo $objectAccessor->SetValue('user_name', 'John Doe');
if ($objectAccessor->hasSetter('userName')) {
echo $objectAccessor->setValue('userName', 'John Doe');
}