1 | <?php |
||
7 | abstract class Enum |
||
8 | { |
||
9 | /** @var string */ |
||
10 | private static $defaultConstantName = '__default'; |
||
11 | /** @var \ReflectionClass[] */ |
||
12 | private static $reflections; |
||
13 | /** @var mixed */ |
||
14 | protected $value; |
||
15 | |||
16 | /** |
||
17 | * @param mixed $value |
||
18 | * |
||
19 | * @throws EnumException |
||
20 | */ |
||
21 | 7 | final public function __construct($value = null) |
|
31 | |||
32 | /** |
||
33 | * @param bool $includeDefault |
||
34 | * |
||
35 | * @return array |
||
36 | */ |
||
37 | 11 | final public static function getConstList(bool $includeDefault = false): array |
|
55 | |||
56 | /** |
||
57 | * Creates enum instance with short static constructor |
||
58 | * |
||
59 | * @param string $name |
||
60 | * @param array $arguments |
||
61 | * |
||
62 | * @return static |
||
63 | * |
||
64 | * @throws \BadMethodCallException |
||
65 | */ |
||
66 | 2 | final public static function __callStatic(string $name, array $arguments) |
|
76 | |||
77 | /** |
||
78 | * @return mixed |
||
79 | * |
||
80 | * @throws EnumException |
||
81 | */ |
||
82 | 3 | protected static function getDefaultValue() |
|
92 | |||
93 | /** |
||
94 | * @return mixed |
||
95 | */ |
||
96 | 6 | final public function getValue() |
|
100 | |||
101 | /** |
||
102 | * Compares one Enum with another. |
||
103 | * |
||
104 | * @param Enum $enum |
||
105 | * |
||
106 | * @return bool True if Enums are equal, false if not equal |
||
107 | */ |
||
108 | 3 | final public function equals(Enum $enum) |
|
112 | |||
113 | /** |
||
114 | * {@inheritdoc} |
||
115 | */ |
||
116 | 1 | public function __toString(): string |
|
120 | |||
121 | /** |
||
122 | * @param mixed $value |
||
123 | * |
||
124 | * @throws EnumException |
||
125 | */ |
||
126 | 6 | private function assertValue($value) |
|
136 | } |
||
137 |