PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / extra / hub-connector / inc / class-singleton.php

class-singleton.php in Defender Security – Malware Scanner, Login Security & Firewall 6.3.0, at extra/hub-connector/inc/class-singleton.php

42 lines 691 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Trait Singleton
4 *
5 * @link http://wpmudev.com
6 * @since 1.0.0
7 * @author Joel James <[email protected]>
8 * @package WPMUDEV\Hub\Connector
9 */
10
11 namespace WPMUDEV\Hub\Connector;
12
13 defined( 'WPINC' ) || die();
14
15 trait Singleton {
16
17 /**
18 * Instance holder.
19 *
20 * @var static $instance
21 */
22 private static $instance;
23
24 /**
25 * Instance obtaining method.
26 *
27 * @since 1.0.0
28 *
29 * @return static Called class instance.
30 */
31 public static function get() {
32 $called_class_name = get_called_class();
33
34 // Only if not already exist.
35 if ( ! self::$instance instanceof $called_class_name ) {
36 self::$instance = new $called_class_name();
37 }
38
39 return self::$instance;
40 }
41 }
42