/** * @dataProvider writeDataProvider */ public function testWrite($propertyPath, $value, $test) { $writer = new PropertyWriter(); $reader = new PropertyReader(); $test = $writer->write($propertyPath, $value, $test); $this->assertEquals($value, $reader->read($propertyPath, $test)); }
/** * Sets a value to an object or array by it property-path. Property-names * are seperated by a dot '.' e.g. * setProperty('foo.bar, 'bazz', array('foo' => array ('bar' => 'foobar!'))) * => will return array('foo' => array ('bar' => 'bazz')) * setProperty('1.bar', 'foobar!', array(array('foo'), array('bar' => 'bazz!'))) * => will return array(array('foo'), array('bar' => 'foobar!')) * The same goes for any kind of object by its getter or public properties. * * @param string $propertyPath The path to the roperty * @param mixed $value The new value to set * @param array|object $target The array or object to retrieve the value from * @return mixed The processed target */ public function setProperty($propertyPath, $value, $target) { return $this->writer->write($this->parsePropertyPath($propertyPath), $value, $target); }