HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: /var/www/html/triad-infosec/wp-content/plugins/imagify/classes/Traits/InstanceGetterTrait.php
<?php
namespace Imagify\Traits;

/**
 * Trait that simulates a singleton pattern.
 * The idea is more to ease the instance retrieval than to prevent multiple instances.
 * This is temporary, until we get a DI container.
 *
 * @since  1.9
 * @since  1.9.4 Renamed into InstanceGetterTrait.
 * @author Grégory Viguier
 */
trait InstanceGetterTrait {

	/**
	 * The "not-so-single" instance of the class.
	 *
	 * @var    ?object
	 * @since  1.9
	 * @access protected
	 * @author Grégory Viguier
	 */
	protected static $instance = null;

	/**
	 * Get the main Instance.
	 *
	 * @since  1.9
	 * @access protected
	 * @author Grégory Viguier
	 *
	 * @return object Main instance.
	 */
	public static function get_instance() {
		if ( ! isset( static::$instance ) ) {
			static::$instance = new static();
		}

		return static::$instance;
	}
}