1 | <?php |
||
10 | abstract class Enum |
||
11 | { |
||
12 | /** |
||
13 | * Enum value |
||
14 | * |
||
15 | * @var mixed |
||
16 | */ |
||
17 | protected $value; |
||
18 | |||
19 | /** |
||
20 | * @var boolean |
||
21 | */ |
||
22 | protected static $multiValued = false; |
||
23 | |||
24 | /** |
||
25 | * @var array |
||
26 | */ |
||
27 | protected static $cache = []; |
||
28 | |||
29 | /** |
||
30 | * Creates a new value of some type |
||
31 | * |
||
32 | * @param mixed $value |
||
33 | * |
||
34 | * @throws \UnexpectedValueException if incompatible type is given. |
||
35 | */ |
||
36 | 10 | final public function __construct($value) |
|
44 | |||
45 | /** |
||
46 | * @return string |
||
47 | */ |
||
48 | 2 | final public function getName() |
|
52 | |||
53 | /** |
||
54 | * @return mixed |
||
55 | */ |
||
56 | 4 | final public function getValue() |
|
60 | |||
61 | /** |
||
62 | * @return string |
||
63 | */ |
||
64 | 2 | final public function __toString() |
|
68 | |||
69 | /** |
||
70 | * Returns all possible values as an array |
||
71 | * |
||
72 | * @return array Constant name in key, constant value in value |
||
73 | */ |
||
74 | 30 | final public static function toArray() |
|
84 | |||
85 | /** |
||
86 | * @return boolean |
||
87 | */ |
||
88 | 20 | final public static function isMultiValued() |
|
92 | |||
93 | /** |
||
94 | * Returns a value when called statically like so: MyEnum::SOME_VALUE() given SOME_VALUE is a class constant |
||
95 | * |
||
96 | * @param string $name |
||
97 | * @param array $arguments |
||
98 | * |
||
99 | * @throws \BadMethodCallException |
||
100 | * |
||
101 | * @return static |
||
102 | */ |
||
103 | final public static function __callStatic($name, $arguments) |
||
111 | } |
||
112 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.