PHP code example of scheb / property-access
1. Go to this page and download the library: Download scheb/property-access 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/ */
scheb / property-access example snippets
$valueObject = ...; // Array or object
$strategies = [
new \Scheb\PropertyAccess\Strategy\ArrayAccessStrategy(),
new \Scheb\PropertyAccess\Strategy\ObjectPropertyAccessStrategy(),
new \Scheb\PropertyAccess\Strategy\ObjectGetterSetterAccessStrategy(),
];
$accessor = new \Scheb\PropertyAccess\PropertyAccess($strategies);
// Returns the value or null
$accessor->getPropertyValue($valueObject, 'propertyName');
// Returns the modified value object or throws FailedSettingPropertyException
$accessor->setPropertyValue($valueObject, 'propertyName', 'newValue');