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