/**
  * @param array $raw
  * @return User
  */
 protected function do_create_object(array $raw)
 {
     $obj = new User($raw['ID']);
     $obj->set_login($raw['user_login']);
     $obj->set_password($raw['user_pass']);
     $obj->set_nicename($raw['user_nicename']);
     $obj->set_email($raw['user_email']);
     $obj->set_url($raw['user_url']);
     $obj->set_registered($raw['user_registered']);
     $obj->set_activation_key($raw['user_activation_key']);
     $obj->set_status($raw['user_status']);
     $obj->set_display_name($raw['display_name']);
     $obj->set_meta($this->get_user_meta($obj->get_id()));
     return $obj;
 }
 /**
  * Import user.
  *
  * @param User $user
  *
  * @todo Here we are assuming that there cannot be two users with the
  * same user_login. This might be wrong. Investigate!
  * Consider using WP function get_user_by.
  *
  * @see http://codex.wordpress.org/Function_Reference/get_user_by
  */
 public function import_user(User $user)
 {
     // Database table base prefix for production and content stage.
     $prod_prefix = $this->custom_dao->get_table_base_prefix();
     $stage_prefix = $this->batch->get_custom_data('sme_table_base_prefix');
     // Change database table base prefix from content staging prefix to
     // production prefix.
     $meta = array_map(function ($record) use($stage_prefix, $prod_prefix) {
         if (isset($record['meta_key']) && strpos($record['meta_key'], $stage_prefix) === 0) {
             $record['meta_key'] = substr_replace($record['meta_key'], $prod_prefix, 0, strlen($stage_prefix));
         }
         return $record;
     }, $user->get_meta());
     // Update user with new meta.
     $user->set_meta($meta);
     // See if user exists in database.
     $existing = $this->user_dao->get_user_by_user_login($user->get_login());
     // Create if user does not exist, update otherwise.
     if (empty($existing)) {
         $this->user_dao->insert($user);
     } else {
         $user->set_id($existing->get_id());
         $this->user_dao->update_user($user);
     }
 }