Exception
11 months ago
AbstractEnum.php
11 months ago
EnumMap.php
11 months ago
NullValue.php
11 months ago
NullValue.php
50 lines
| 1 | <?php |
| 2 | |
| 3 | declare (strict_types=1); |
| 4 | namespace WP2FA_Vendor\DASPRiD\Enum; |
| 5 | |
| 6 | use WP2FA_Vendor\DASPRiD\Enum\Exception\CloneNotSupportedException; |
| 7 | use WP2FA_Vendor\DASPRiD\Enum\Exception\SerializeNotSupportedException; |
| 8 | use WP2FA_Vendor\DASPRiD\Enum\Exception\UnserializeNotSupportedException; |
| 9 | final class NullValue |
| 10 | { |
| 11 | /** |
| 12 | * @var self |
| 13 | */ |
| 14 | private static $instance; |
| 15 | private function __construct() |
| 16 | { |
| 17 | } |
| 18 | public static function instance() : self |
| 19 | { |
| 20 | return self::$instance ?: (self::$instance = new self()); |
| 21 | } |
| 22 | /** |
| 23 | * Forbid cloning enums. |
| 24 | * |
| 25 | * @throws CloneNotSupportedException |
| 26 | */ |
| 27 | public final function __clone() |
| 28 | { |
| 29 | throw new CloneNotSupportedException(); |
| 30 | } |
| 31 | /** |
| 32 | * Forbid serializing enums. |
| 33 | * |
| 34 | * @throws SerializeNotSupportedException |
| 35 | */ |
| 36 | public final function __sleep() : array |
| 37 | { |
| 38 | throw new SerializeNotSupportedException(); |
| 39 | } |
| 40 | /** |
| 41 | * Forbid unserializing enums. |
| 42 | * |
| 43 | * @throws UnserializeNotSupportedException |
| 44 | */ |
| 45 | public final function __wakeup() : void |
| 46 | { |
| 47 | throw new UnserializeNotSupportedException(); |
| 48 | } |
| 49 | } |
| 50 |