1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
<?php /** * Singleton class trait. * * @package WooCommerce\Utilities */
namespace Automattic\WooCommerce\RestApi\Utilities;
/** * Singleton trait. */ trait SingletonTrait { /** * 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. */ final public function __wakeup() { wc_doing_it_wrong( __FUNCTION__, __( 'Unserializing instances of this class is forbidden.', 'woocommerce' ), '4.6' ); die(); } }
|