| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * @author : Jagepard <[email protected]> |
||
| 5 | * @license https://mit-license.org/ MIT |
||
| 6 | */ |
||
| 7 | |||
| 8 | namespace AntiPatterns\Singleton; |
||
| 9 | |||
| 10 | final class Singleton |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var Singleton |
||
| 14 | */ |
||
| 15 | private static $instance; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Gets an object instance |
||
| 19 | * -------------------------- |
||
| 20 | * Получает экземпляр объекта |
||
| 21 | * |
||
| 22 | * @return self |
||
| 23 | */ |
||
| 24 | public static function getInstance(): self |
||
| 25 | { |
||
| 26 | if (!self::$instance instanceof self) { |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 27 | self::$instance = new self(); |
||
| 28 | } |
||
| 29 | |||
| 30 | return self::$instance; |
||
| 31 | } |
||
| 32 | |||
| 33 | public function __construct() |
||
| 34 | { |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @codeCoverageIgnore |
||
| 39 | */ |
||
| 40 | public function __sleep() |
||
| 41 | { |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @codeCoverageIgnore |
||
| 46 | */ |
||
| 47 | public function __wakeup() |
||
| 48 | { |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @codeCoverageIgnore |
||
| 53 | */ |
||
| 54 | public function __clone() |
||
| 55 | { |
||
| 56 | } |
||
| 57 | } |
||
| 58 |