1 | <?php |
||
19 | class Enum |
||
20 | { |
||
21 | /** @var int|double|string|boolean The value. */ |
||
22 | private $value; |
||
23 | |||
24 | /** |
||
25 | * Construct a enum with the given value. |
||
26 | * |
||
27 | * @param int|double|string|boolean $value |
||
28 | * @throws \UnexpectedValueException |
||
29 | */ |
||
30 | public function __construct($value) |
||
38 | |||
39 | /** |
||
40 | * Returns the string representation of the enum object. |
||
41 | * |
||
42 | * @return string the string representation of the enum object. |
||
43 | */ |
||
44 | public function __toString() |
||
48 | |||
49 | /** |
||
50 | * Returns the ordinal. |
||
51 | * |
||
52 | * @return int the ordinal. |
||
53 | */ |
||
54 | public function getOrdinal() |
||
60 | |||
61 | /** |
||
62 | * Returns the name. |
||
63 | * |
||
64 | * @return string the name. |
||
65 | */ |
||
66 | public function getName() |
||
72 | |||
73 | /** |
||
74 | * Returns the value. |
||
75 | * |
||
76 | * @return mixed the value; |
||
77 | */ |
||
78 | public function getValue() |
||
82 | |||
83 | /** |
||
84 | * Returns the enum objects. |
||
85 | * |
||
86 | * @return array<string,integer|double|string|boolean> the enum objects. |
||
87 | */ |
||
88 | public static function toArray() |
||
92 | |||
93 | /** |
||
94 | * Returns the enum object with the specified name. |
||
95 | * |
||
96 | * @param string $name |
||
97 | * @return Enum the enum object with the specified name. |
||
98 | * @throws \UnexpectedValueException |
||
99 | */ |
||
100 | public static function valueOf($name) |
||
108 | } |
||
109 |