src/MapperTrait.php
public function populateObject($object, \stdClass $mapped, $meta=null)
    {
        if (!$meta instanceof Meta) {
            $meta = $this->getMeta($meta ?: get_class($object));
            if (!$meta) {
                throw new \InvalidArgumentException();
            }
        }

        $properties = $meta->getProperties();
        foreach ($mapped as $prop=>$value) {
            if (!isset($properties[$prop])) {
                throw new \UnexpectedValueException("Property $prop does not exist on class {$meta->class}");
            }
            $property = $properties[$prop];
            if (!isset($property['setter'])) {
                $object->{$prop} = $value;
            }
            else {
                // false setter means read only
                if ($property['setter'] !== false) {
                    call_user_func(array($object, $property['setter']), $value);
                }
            }
        }
    }
public function populateObject($object, \stdClass $mapped, $meta=null)
    {
        if (!$meta instanceof Meta) {
            $meta = $this->getMeta($meta ?: get_class($object));
            if (!$meta) {
                throw new \InvalidArgumentException();
            }
        }

        $properties = $meta->getProperties();
        foreach ($mapped as $prop=>$value) {
            if (!isset($properties[$prop])) {
                throw new \UnexpectedValueException("Property $prop does not exist on class {$meta->class}");
            }
            $property = $properties[$prop];
            if (!isset($property['setter'])) {
                $object->{$prop} = $value;
            }
            else {
                // false setter means read only
                if ($property['setter'] !== false) {
                    call_user_func(array($object, $property['setter']), $value);
                }
            }
        }
    }
public function populateObject ( $ object , \ stdClass $ mapped , $ meta = null ) { if ( ! $ meta instanceof Meta ) { $ meta = $ this -> getMeta ( $ meta ? : get_class ( $ object ) ) ; if ( ! $ meta ) { throw new \ InvalidArgumentException ( ) ; } } $ properties = $ meta -> getProperties ( ) ; foreach ( $ mapped as $ prop => $ value ) { if ( ! isset ( $ properties [ $ prop ] ) ) { throw new \ UnexpectedValueException ( "Property $prop does not exist on class {$meta->class}" ) ; } $ property = $ properties [ $ prop ] ; if ( ! isset ( $ property [ 'setter' ] ) ) { $ object -> { $ prop } = $ value ; } else { // false setter means read only if ( $ property [ 'setter' ] !== false ) { call_user_func ( array ( $ object , $ property [ 'setter' ] ) , $ value ) ; } } } }
Populate an object with row values

@param $meta  Amiss\Meta|string
@param object $object
@param array  $mapped Input after mapping to property names and type handling
@return void
Populate an object with row values