1 | <?php |
||
11 | abstract class Enum |
||
12 | { |
||
13 | |||
14 | /** |
||
15 | * @var string[] |
||
16 | */ |
||
17 | protected static $values = []; |
||
18 | |||
19 | /** |
||
20 | * @var $this[] |
||
21 | */ |
||
22 | protected static $instances = []; |
||
23 | |||
24 | /** |
||
25 | * @var string |
||
26 | */ |
||
27 | protected $value; |
||
28 | |||
29 | /** |
||
30 | * PROTECTED!! Not callable directly. |
||
31 | * @see static::instance() |
||
32 | * @see static::__callStatic() |
||
33 | * @internal |
||
34 | * |
||
35 | * @param string $value |
||
36 | */ |
||
37 | 4 | protected function __construct($value) |
|
47 | |||
48 | /** |
||
49 | * String representation |
||
50 | */ |
||
51 | 1 | public function __toString() |
|
55 | |||
56 | /** |
||
57 | * @param string $method |
||
58 | * @param array $args |
||
59 | * |
||
60 | * @return \SpareParts\Enum\Enum |
||
61 | */ |
||
62 | 7 | public static function __callStatic($method, $args) |
|
66 | |||
67 | /** |
||
68 | * @param string $value |
||
69 | * |
||
70 | * @return $this |
||
71 | */ |
||
72 | 9 | public static function instance($value) |
|
80 | |||
81 | 1 | public function __clone() |
|
85 | |||
86 | 1 | public function __sleep() |
|
90 | |||
91 | 1 | public function __wakeup() |
|
95 | } |
||
96 |