Source of file Singleton.php
Size: 1,234 Bytes - Last Modified: 2017-11-08T13:54:24+00:00
/home/travis/build/bluzphp/framework/src/Common/Singleton.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 | <?php /** * Bluz Framework Component * * @copyright Bluz PHP Team * @link https://github.com/bluzphp/framework */ declare(strict_types=1); namespace Bluz\Common; /** * Singleton * * @package Bluz\Common * @author Anton Shevchuk * @link https://github.com/bluzphp/framework/wiki/Trait-Singleton */ trait Singleton { /** * @var static singleton instance */ protected static $instance; /** * Get instance * * @return static */ public static function getInstance() { return static::$instance ?? (static::$instance = static::initInstance()); } /** * Initialization of class instance * * @return static */ private static function initInstance() { return new static; } /** * Reset instance * * @return void */ public static function resetInstance() { static::$instance = null; } /** * Disabled by access level */ private function __construct() { } /** * Disabled by access level */ private function __clone() { } /** * Disabled by access level */ private function __wakeup() { } } |