52 lines
735 B
PHP
52 lines
735 B
PHP
|
<?php
|
||
|
/**
|
||
|
* Abstract singleton class.
|
||
|
*
|
||
|
* @package WooCommerce/Rest_Api
|
||
|
*/
|
||
|
|
||
|
namespace WooCommerce\Rest_Api;
|
||
|
|
||
|
defined( 'ABSPATH' ) || exit;
|
||
|
|
||
|
/**
|
||
|
* Singleton trait.
|
||
|
*/
|
||
|
trait Singleton {
|
||
|
/**
|
||
|
* The single instance of the class.
|
||
|
*
|
||
|
* @var object
|
||
|
*/
|
||
|
protected static $instance = null;
|
||
|
|
||
|
/**
|
||
|
* Constructor
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
protected function __construct() {}
|
||
|
|
||
|
/**
|
||
|
* Get class instance.
|
||
|
*
|
||
|
* @return object Instance.
|
||
|
*/
|
||
|
final public static function instance() {
|
||
|
if ( null === static::$instance ) {
|
||
|
static::$instance = new static();
|
||
|
}
|
||
|
return static::$instance;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Prevent cloning.
|
||
|
*/
|
||
|
private function __clone() {}
|
||
|
|
||
|
/**
|
||
|
* Prevent unserializing.
|
||
|
*/
|
||
|
private function __wakeup() {}
|
||
|
}
|