PluginProbe
YayMail – WooCommerce Email Customizer / trunk
YayMail – WooCommerce Email Customizer vtrunk
4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 3.4.2 3.4.3 All 55 releases
yaymail / src / Utils / SingletonTrait.php

SingletonTrait.php in YayMail – WooCommerce Email Customizer trunk, at src/Utils/SingletonTrait.php

25 lines 577 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace YayMail\Utils;
3
4 trait SingletonTrait {
5 private static $instance;
6
7 public static function get_instance( ...$args ) {
8 $class = get_called_class();
9 if ( ! $class::$instance ) {
10 $class::$instance = new $class( ...$args );
11 }
12
13 return $class::$instance;
14 }
15
16 /** Singletons should not be cloneable. */
17 protected function __clone() { }
18
19 /** Singletons should not be restorable from strings. */
20 public function __wakeup() {
21 throw new \Exception( 'Cannot unserialize a singleton.' );
22 }
23 }
24
25