-
Notifications
You must be signed in to change notification settings - Fork 0
Readers
Rafael Santos edited this page Jun 27, 2016
·
1 revision
Readers are similars to writers but are used to create the array from object.
By default the library use Rafrsr\LibArray2Object\Reader\AccessorReader
this reader require the getter method of each property to get the value, otherwise the value is not getted.
Can use one of the following readers:
Require the getter in the object to work.
Read values directly on propertiers, optionally can read only public properties.
$object2Array = Object2Array::create()->setReader(new ReflectionReader())->build();
Can implements your own reader class implementing Rafrsr\LibArray2Object\Reader\PropertyReaderInterface
class CustomReader implements PropertyReaderInterface
{
/**
* @inheritDoc
*/
public function isReadable($object, $propertyPath)
{
// TODO: Implement isReadable() method.
}
/**
* @inheritDoc
*/
public function getValue(&$object, $propertyPath)
{
// TODO: Implement getValue() method.
}
}