# solid-performance/1.4.0/src/Performance/Plugin/Uninstaller.php

Solid Performance – Your No-Code Caching, Performance, &amp; Page Speed Solution, version 1.4.0. 96 lines.

- Page: https://pluginprobe.com/plugins/solid-performance/1.4.0/code/src/Performance/Plugin/Uninstaller.php
- Raw: https://pluginprobe.com/plugins/solid-performance/1.4.0/raw/src/Performance/Plugin/Uninstaller.php
- Modified: 2025-02-12T22:54:40+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/solid-performance/1.4.0/code/src/Performance/Plugin/Uninstaller.php#L10-L20`.

```php
<?php
/**
 * All functionality related to uninstalling the plugin.
 *
 * @package SolidWP\Performance
 */

declare( strict_types=1 );

namespace SolidWP\Performance\Plugin;

use SolidWP\Performance\Container;
use SolidWP\Performance\Database\Provider;
use SolidWP\Performance\StellarWP\Schema\Register;
use SolidWP\Performance\StellarWP\Schema\Tables\Contracts\Table;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Handles actions that should run when the plugin is uninstalled.
 *
 * WordPress does not allow anonymous callbacks with register_uninstall_hook.
 *
 * @package SolidWP\Performance
 */
final class Uninstaller {

	/**
	 * @var Container
	 */
	private Container $container;

	/**
	 * The Singleton instance.
	 *
	 * @var self|null
	 */
	private static ?self $instance = null;

	/**
	 * @param  Container $container The container.
	 */
	private function __construct( Container $container ) {
		$this->container = $container;
	}

	/**
	 * Get the singleton instance.
	 *
	 * @return self
	 */
	public static function instance(): self {
		if ( self::$instance === null ) {
			self::$instance = new self( swpsp_plugin()->container() );
		}

		return self::$instance;
	}

	/**
	 * Uninstall hook run via register_uninstall_hook().
	 *
	 * @return void
	 */
	public static function uninstall(): void {
		self::instance()->handle_uninstall();
	}

	/**
	 * Actual uninstall logic.
	 *
	 * @return void
	 */
	private function handle_uninstall(): void {
		$this->remove_database_tables();
	}

	/**
	 * Remove database tables.
	 *
	 * @return void
	 */
	private function remove_database_tables(): void {
		$this->container->get( Provider::class )->register();

		$tables = $this->container->get( Provider::SCHEMA_TABLES );

		/** @var class-string<Table> $table */
		foreach ( $tables as $table ) {
			Register::remove_table( $table );
		}
	}
}

```
