protected function _fillFromArray($entity, $data)
    { 
      
      if ($data) {
        
        foreach ($data as $key => $value) {
            if (is_array($value)) {
                $className = 'MercadoPago\\' . $this->_camelize($key);
                if (class_exists($className, true)) {
                    $entity->_setValue($key, new $className, false);
                    $entity->_fillFromArray($this->{$key}, $value);
                } else {
                    $entity->_setValue($key, json_decode(json_encode($value)), false);
                }
                continue;
            }
            $entity->_setValue($key, $value, false);
        }
      }
    }
protected function _fillFromArray($entity, $data)
    { 
      
      if ($data) {
        
        foreach ($data as $key => $value) {
            if (is_array($value)) {
                $className = 'MercadoPago\\' . $this->_camelize($key);
                if (class_exists($className, true)) {
                    $entity->_setValue($key, new $className, false);
                    $entity->_fillFromArray($this->{$key}, $value);
                } else {
                    $entity->_setValue($key, json_decode(json_encode($value)), false);
                }
                continue;
            }
            $entity->_setValue($key, $value, false);
        }
      }
    }
protected function _fillFromArray ( $ entity , $ data ) { if ( $ data ) { foreach ( $ data as $ key => $ value ) { if ( is_array ( $ value ) ) { $ className = 'MercadoPago\\' . $ this -> _camelize ( $ key ) ; if ( class_exists ( $ className , true ) ) { $ entity -> _setValue ( $ key , new $ className , false ) ; $ entity -> _fillFromArray ( $ this -> { $ key } , $ value ) ; } else { $ entity -> _setValue ( $ key , json_decode ( json_encode ( $ value ) ) , false ) ; } continue ; } $ entity -> _setValue ( $ key , $ value , false ) ; } } }
Fill entity from data with nested object creation

@param $entity
@param $data
Fill entity from data with nested object creation