3 namespace pq\Mapper\Property
;
8 use pq\Mapper\Property
;
9 use pq\Mapper\PropertyInterface
;
11 class Field
implements PropertyInterface
16 * Create a simple field mapping
17 * @param Mapper $mapper
18 * @param string $property
19 * @param string $field
21 function __construct(Mapper
$mapper, $property, $field = null) {
22 $this->mapper
= $mapper;
23 $this->property
= $property;
24 $this->field
= $field ?
: $property;
30 * @param object $objectToUpdate
32 function read(Row
$row, $objectToUpdate) {
34 $val = $row->{$this->field
};
35 $this->assign($objectToUpdate, $val->get());
39 * Write property value
40 * @param object $object
41 * @param Row $rowToUpdate
43 function write($object, Row
$rowToUpdate) {
44 $val = $this->extract($object);
45 $rowToUpdate->{$this->field
} = $val;