2023-08-09 11:48:49 +01:00
|
|
|
<?php
|
|
|
|
|
2023-08-14 12:00:40 +01:00
|
|
|
namespace WooCommerce\PayPalCommerce\Isolated\Pattern;
|
2023-08-09 11:48:49 +01:00
|
|
|
|
|
|
|
trait SingletonTrait {
|
|
|
|
/**
|
|
|
|
* The single instance of the class.
|
|
|
|
*
|
|
|
|
* @var self
|
|
|
|
*/
|
|
|
|
protected static $instance = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Static method to get the instance of the Singleton class
|
|
|
|
*
|
|
|
|
* @return self|null
|
|
|
|
*/
|
|
|
|
public static function get_instance(): ?self {
|
|
|
|
return self::$instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Static method to get the instance of the Singleton class
|
|
|
|
*
|
|
|
|
* @param self $instance
|
|
|
|
* @return self
|
|
|
|
*/
|
|
|
|
protected static function set_instance( self $instance ): self {
|
|
|
|
self::$instance = $instance;
|
|
|
|
return self::$instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|