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 | * @param bool $deprecate |
||
19 | * |
||
20 | * @throws EnumException |
||
21 | 3 | * |
|
22 | * @deprecated use by-name constructor instead |
||
23 | 3 | * @see Enum::createByName |
|
24 | 3 | * @see Enum::__callStatic |
|
25 | */ |
||
26 | final public function __construct($value = null, bool $deprecate = true) |
||
40 | 6 | ||
41 | 1 | /** |
|
42 | * @param bool $includeDefault |
||
43 | * |
||
44 | 5 | * @return array |
|
45 | */ |
||
46 | final public static function getConstList(bool $includeDefault = false): array |
||
66 | 5 | ||
67 | /** |
||
68 | * Creates enum instance by name |
||
69 | 5 | * |
|
70 | * @param string $name |
||
71 | 5 | * |
|
72 | * @return static |
||
73 | * |
||
74 | 7 | * @throws \BadMethodCallException |
|
75 | */ |
||
76 | 7 | final public static function createByName(string $name) |
|
98 | |||
99 | /** |
||
100 | 5 | * Creates enum instance with short static constructor |
|
101 | * |
||
102 | * @param string $name |
||
103 | 1 | * @param array $arguments |
|
104 | * |
||
105 | 1 | * @return static |
|
106 | * |
||
107 | * @throws \BadMethodCallException |
||
108 | */ |
||
109 | final public static function __callStatic(string $name, array $arguments) |
||
113 | 1 | ||
114 | /** |
||
115 | * @return mixed |
||
116 | * |
||
117 | * @throws EnumException |
||
118 | * |
||
119 | * @deprecated |
||
120 | */ |
||
121 | protected static function getDefaultValue() |
||
133 | |||
134 | /** |
||
135 | * @return mixed |
||
136 | * |
||
137 | * @deprecated Cast to string instead |
||
138 | */ |
||
139 | final public function getValue() |
||
145 | |||
146 | /** |
||
147 | * Compares one Enum with another. |
||
148 | * |
||
149 | * @param Enum $enum |
||
150 | * |
||
151 | * @return bool True if Enums are equal, false if not equal |
||
152 | * |
||
153 | * @deprecated Use weak comparison instead |
||
154 | */ |
||
155 | final public function equals(Enum $enum): bool |
||
161 | |||
162 | /** |
||
163 | * {@inheritdoc} |
||
164 | */ |
||
165 | public function __toString(): string |
||
169 | |||
170 | /** |
||
171 | * @param mixed $value |
||
172 | * |
||
173 | * @throws EnumException |
||
174 | */ |
||
175 | private function assertValue($value) |
||
185 | } |
||
186 |
This method has been deprecated.