PHP code example of jonmldr / property-accessor
1. Go to this page and download the library: Download jonmldr/property-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/ */
jonmldr / property-accessor example snippets
$propertyAccessor = new PropertyAccessor();
// Will throw an `NoAccessMethodException` if there is no method to access the property.
$repositoryName = $propertyAccessor->getValue('users[0].repositories[0].name', $userGroup);
$accessMethod = $this->propertyAccessor->getAccessMethod('licensePlate', Car::class);
if ($accessMethod instanceof MethodAccessMethod) {
// The value will be accessed by a method.
$methodName = $accessMethod->getMethodName();
} elseif ($accessMethod instanceof ProperyAccessMethod) {
// The value will be accessed by a (public) property.
$propertyName = $accessMethod->getPropertyName();
} elseif ($accessMethod === null) {
// No access method found.
}