HEX
Server: Apache/2.4.54 (Debian)
System: Linux a5825d2beacc 4.15.0-197-generic #208-Ubuntu SMP Tue Nov 1 17:23:37 UTC 2022 x86_64
User: root (0)
PHP: 8.1.14
Disabled: NONE
Upload Files
File: /var/www/html/wp-content/plugins/eth-embed-fm/inc/trait-singleton.php
<?php
/**
 * Singleton trait.
 *
 * @package ETH_Embed_Anchor_FM
 */

namespace ETH_Embed_Anchor_FM;

/**
 * Trait Singleton.
 */
trait Singleton {
	/**
	 * Singleton.
	 *
	 * @var self
	 */
	private static $_instance = null;

	/**
	 * Implement singleton.
	 *
	 * @return self
	 */
	public static function get_instance(): self {
		if ( ! is_a( self::$_instance, __CLASS__ ) ) {
			self::$_instance = new self();
			self::$_instance->_setup();
		}

		return self::$_instance;
	}

	/**
	 * Silence is golden!
	 */
	private function __construct() {
		// Add nothing here.
	}

	/**
	 * Register hooks.
	 *
	 * @return void
	 */
	abstract protected function _setup(): void;
}