protected function restoreObject($entity, array $restore, \ReflectionClass $ref)
    {
        foreach ($restore as $field => $type) {
            if (is_array($entity)) {
                if (!isset($entity[$field])) {
                    continue;
                }

                $entity[$field] = $this->convertToPHPValue($entity[$field], $type);
                continue;
            }

            if (!$ref->hasProperty($field)) {
                if (!isset($entity->$field)) {
                    continue;
                }

                $entity->$field = $this->convertToPHPValue($entity->$field, $type);
                continue;
            }

            $prop = $ref->getProperty($field);
            $prop->setAccessible(true);

            $value = $prop->getValue($entity);
            $value = $this->convertToPHPValue($value, $type);
            $prop->setValue($entity, $value);
        }

        return $entity;
    }
protected function restoreObject($entity, array $restore, \ReflectionClass $ref)
    {
        foreach ($restore as $field => $type) {
            if (is_array($entity)) {
                if (!isset($entity[$field])) {
                    continue;
                }

                $entity[$field] = $this->convertToPHPValue($entity[$field], $type);
                continue;
            }

            if (!$ref->hasProperty($field)) {
                if (!isset($entity->$field)) {
                    continue;
                }

                $entity->$field = $this->convertToPHPValue($entity->$field, $type);
                continue;
            }

            $prop = $ref->getProperty($field);
            $prop->setAccessible(true);

            $value = $prop->getValue($entity);
            $value = $this->convertToPHPValue($value, $type);
            $prop->setValue($entity, $value);
        }

        return $entity;
    }
protected function restoreObject ( $ entity , array $ restore , \ ReflectionClass $ ref ) { foreach ( $ restore as $ field => $ type ) { if ( is_array ( $ entity ) ) { if ( ! isset ( $ entity [ $ field ] ) ) { continue ; } $ entity [ $ field ] = $ this -> convertToPHPValue ( $ entity [ $ field ] , $ type ) ; continue ; } if ( ! $ ref -> hasProperty ( $ field ) ) { if ( ! isset ( $ entity -> $ field ) ) { continue ; } $ entity -> $ field = $ this -> convertToPHPValue ( $ entity -> $ field , $ type ) ; continue ; } $ prop = $ ref -> getProperty ( $ field ) ; $ prop -> setAccessible ( true ) ; $ value = $ prop -> getValue ( $ entity ) ; $ value = $ this -> convertToPHPValue ( $ value , $ type ) ; $ prop -> setValue ( $ entity , $ value ) ; } return $ entity ; }
Restores entity values from their stored representation

@param object           $entity
@param array            $restore
@param \ReflectionClass $ref

@return mixed
Restores entity values from their stored representation