Skip to content

Commit e289197

Browse files
committed
create singleton design pattern
1 parent 35aa338 commit e289197

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Creational/Singleton/Singleton.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace DesignPatterns\Creational\Singleton;
66

7+
use LogicException;
8+
79
final class Singleton
810
{
911
private static ?Singleton $instance = null;
@@ -25,8 +27,9 @@ private function __clone()
2527
{
2628
}
2729

28-
private function __wakeup()
30+
public function __wakeup()
2931
{
32+
throw new LogicException('Cannot unserialize a singleton.');
3033
}
3134

3235
private function __sleep()

0 commit comments

Comments
 (0)