PluginProbe
WP Console – WordPress PHP Console powered by PsySH / 2.5.1
WP Console – WordPress PHP Console powered by PsySH v2.5.1
trunk 2.4.0 2.4.1 2.5.0 2.5.1 2.6.0
wp-console / includes / Traits / Singleton.php

Singleton.php in WP Console – WordPress PHP Console powered by PsySH 2.5.1, at includes/Traits/Singleton.php

40 lines 677 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPConsole\Traits;
4
5 /**
6 * Singleton Trait
7 *
8 * @since 1.0.0
9 */
10 trait Singleton {
11
12 /**
13 * Singleton class instance holder
14 *
15 * @since 1.0.0
16 *
17 * @var object
18 */
19 private static $instance;
20
21 /**
22 * Make a class instance
23 *
24 * @since 1.0.0
25 *
26 * @return object
27 */
28 public static function instance() {
29 if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) {
30 self::$instance = new self();
31
32 if ( method_exists( self::$instance, 'boot' ) ) {
33 self::$instance->boot();
34 }
35 }
36
37 return self::$instance;
38 }
39 }
40