-
Notifications
You must be signed in to change notification settings - Fork 0
Writers
Rafael Santos edited this page Jun 22, 2016
·
1 revision
Writers are used to set the array parsed value in the matched object property.
By default the library use Rafrsr\LibArray2Object\Writer\AccessorWriter
this writer require the setter method of each property to set the value, otherwise the value is not settled.
Can use one of the following writers:
Require the setter in the object to work.
Write values directly on propeties, optionally can write only public properties.
$array2Object = Array2ObjectBuilder::create()->setWriter(new ReflectionWriter())->build();
Can implements your own writer class implementing Rafrsr\LibArray2Object\Writer\PropertyWriterInterface
class CustomWriter implements PropertyWriterInterface
{
/**
* @inheritDoc
*/
public function isWritable($object, $propertyPath)
{
// TODO: Implement isWritable() method.
}
/**
* @inheritDoc
*/
public function setValue(&$object, $propertyPath, $value)
{
// TODO: Implement setValue() method.
}
}