1 | <?php |
||
7 | abstract class AbstractEnum |
||
8 | { |
||
9 | /** |
||
10 | * String value of enum. |
||
11 | * |
||
12 | * @var string |
||
13 | */ |
||
14 | private $value; |
||
15 | |||
16 | /** |
||
17 | * Construct a new AbstractEnum object. |
||
18 | * |
||
19 | * @param string $value The string value of the enum. |
||
20 | */ |
||
21 | final private function __construct(string $value) |
||
25 | |||
26 | /** |
||
27 | * Returns the string value of the enum. |
||
28 | * |
||
29 | * @return string |
||
30 | */ |
||
31 | final public function __toString() : string |
||
35 | |||
36 | /** |
||
37 | * Returns a new instance of the AbstractEnum class. |
||
38 | * |
||
39 | * @param string $name The string value of the enum. |
||
40 | * @param array $arguments Unused. |
||
41 | * |
||
42 | * @return AbstractEnum |
||
43 | * |
||
44 | * @throws \UnexpectedValueException Thrown if $name is not a defined Enum constant. |
||
45 | */ |
||
46 | final public static function __callStatic(string $name, /** @scrutinizer ignore-unused */array $arguments) : self |
||
55 | |||
56 | /** |
||
57 | * Returns an array of all enums. |
||
58 | * |
||
59 | * @return AbstractEnum[] |
||
60 | */ |
||
61 | final public static function all() : array |
||
73 | } |
||
74 |