hgg/property-accessor

The Symfony PropertyAccessor as a trait

v1.0.1 2017-09-03 18:41 UTC

This package is not auto-updated.

Last update: 2024-10-22 23:45:30 UTC


README

Provide a bit of convenience if your property access methods need to throw exceptions on an as needed basis.

Example:

$default = 'my default';
$throw   = false;
$value   = $this->getValue($obj, 'my.path.to.value', $default, $throw);

This would return the value at the given path if it exists, or the default value if not.

$default = 'my default';
$throw   = true;
$value   = $this->getValue($obj, 'my.path.to.value', $default, $throw);

This would return the value at the given path if it exists, or throw an exception if not.