Array_To_CSV.php
3 years ago
Currency.php
3 years ago
Number_Formatter.php
3 years ago
Option.php
3 years ago
Request.php
3 years ago
Salt.php
3 years ago
Security.php
3 years ago
Singleton.php
3 years ago
String_Util.php
3 years ago
Timezone.php
3 years ago
URL.php
3 years ago
WP_Async_Request.php
3 years ago
WordPress_Site_Date_Format_Pattern.php
3 years ago
Singleton.php
57 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP_SCOPED\IAWP\Utils; |
| 4 | |
| 5 | trait Singleton |
| 6 | { |
| 7 | /** |
| 8 | * Singleton Instance |
| 9 | * |
| 10 | * @var mixed |
| 11 | */ |
| 12 | private static $instance = null; |
| 13 | /** |
| 14 | * Private Constructor |
| 15 | * |
| 16 | * We can't use the constructor to create an instance of the class |
| 17 | * |
| 18 | * @return void |
| 19 | */ |
| 20 | private function __construct() |
| 21 | { |
| 22 | // Don't do anything, we don't want to be initialized |
| 23 | } |
| 24 | /** |
| 25 | * Get the singleton instance |
| 26 | * |
| 27 | * @return self |
| 28 | */ |
| 29 | public static function getInstance() : self |
| 30 | { |
| 31 | if (\is_null(self::$instance)) { |
| 32 | self::$instance = new self(); |
| 33 | } |
| 34 | return self::$instance; |
| 35 | } |
| 36 | /** |
| 37 | * Private clone method to prevent cloning of the instance of the |
| 38 | * Singleton instance. |
| 39 | * |
| 40 | * @return void |
| 41 | */ |
| 42 | private function __clone() |
| 43 | { |
| 44 | // Don't do anything, we don't want to be cloned |
| 45 | } |
| 46 | /** |
| 47 | * Private unserialize method to prevent unserializing of the Singleton |
| 48 | * instance. |
| 49 | * |
| 50 | * @return void |
| 51 | */ |
| 52 | public function __wakeup() |
| 53 | { |
| 54 | // Don't do anything, we don't want to be unserialized |
| 55 | } |
| 56 | } |
| 57 |