1 | <?php |
||
13 | abstract class Enumerated implements ValueHolder |
||
14 | { |
||
15 | /** @var string */ |
||
16 | private $value; |
||
17 | /** @var boolean */ |
||
18 | private $valid = true; |
||
19 | |||
20 | 3 | protected function __construct() |
|
24 | |||
25 | /** |
||
26 | * @return string |
||
27 | */ |
||
28 | 7 | public function getValue() |
|
32 | |||
33 | /** |
||
34 | * @return boolean |
||
35 | */ |
||
36 | 5 | public function isValid() |
|
40 | |||
41 | /** |
||
42 | * @return string |
||
43 | */ |
||
44 | 4 | final public function __toString() |
|
49 | |||
50 | /** |
||
51 | * static initializer to set up all enum values |
||
52 | */ |
||
53 | 1 | final public static function init() |
|
64 | |||
65 | /** |
||
66 | * Get an instance of the enum with a value of 'null'. |
||
67 | * |
||
68 | * This might be handy if we need an instance of the Enum to work with but |
||
69 | * we do not really care about a real value being set. |
||
70 | * |
||
71 | * @return static |
||
72 | */ |
||
73 | 1 | final public static function void() |
|
77 | |||
78 | /** |
||
79 | * Get Enum for the given input |
||
80 | * |
||
81 | * @param string|mixed $value |
||
82 | * |
||
83 | * @return static |
||
84 | */ |
||
85 | 5 | final public static function from($value) |
|
115 | |||
116 | /** |
||
117 | * @return string[] |
||
118 | */ |
||
119 | 1 | final public static function enumerateValues() |
|
123 | |||
124 | /** |
||
125 | * @return array|Enumerated[] |
||
126 | */ |
||
127 | 6 | final public static function enumerateProps() |
|
131 | |||
132 | /** |
||
133 | * @return \ReflectionClass |
||
134 | */ |
||
135 | 7 | final public static function getReflection() |
|
140 | } |
||
141 |