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