<?php

namespace Lcmigrator\LcMigrator\ImporterV2;

use Lcmigrator\LcMigrator\Database\DatabaseUtilityFunctions;

class CleanComplete {
    public static function execute( $params ) {
        // Clean up the database
        $db_client = DatabaseUtilityFunctions::create_client();

		// Flush mainsite tables
		$db_client->add_table_prefix_filter( lc_migrator_table_prefix( 'mainsite' ) );
		$db_client->flush();

		// Delete The Extracted Backup Directory
		$backup_dir = $params['temp_dir'];
		lc_migrator_recursive_directory_delete($backup_dir);
        
		// Exit in console
		if ( defined( 'WP_CLI' ) ) {
			return $params;
		}
    }
}