1 | <?php |
||
15 | abstract class Enum |
||
16 | { |
||
17 | /** @var Entry */ |
||
18 | private $content; |
||
19 | |||
20 | 5 | final public function value(): string |
|
24 | |||
25 | 5 | final public function index(): int |
|
29 | |||
30 | 2 | final public function __toString(): string |
|
34 | |||
35 | /** |
||
36 | * Enum constructor. |
||
37 | * |
||
38 | * @param string|int|mixed $valueOrIndex |
||
39 | * |
||
40 | * @throws IndexNotFoundException if received argument is an integer and it was not found in indices |
||
41 | * @throws ValueNotFoundException if received argument is a string and it was not found in values |
||
42 | * @throws EnumConstructTypeError if received argument is not an integer, string, scalar or object |
||
43 | */ |
||
44 | 22 | final public function __construct($valueOrIndex) |
|
71 | |||
72 | 9 | public function __call($name, $arguments) |
|
81 | |||
82 | 13 | public static function __callStatic($name, $arguments) |
|
91 | |||
92 | 4 | final public static function toArray(): array |
|
96 | |||
97 | /** |
||
98 | * Method to override values |
||
99 | * |
||
100 | * It must return an array with key as the name declared in docblock |
||
101 | * and value as the string value to use. |
||
102 | * |
||
103 | * Example: |
||
104 | * method self extraSmall() |
||
105 | * return ['extraSmall' => 'xs', ...]; |
||
106 | * |
||
107 | * @return array |
||
108 | */ |
||
109 | 3 | protected static function overrideValues(): array |
|
113 | |||
114 | /** |
||
115 | * Method to override indices |
||
116 | * |
||
117 | * It must return an array with key as the name declared in docblock |
||
118 | * and value as the integer index to use. |
||
119 | * |
||
120 | * Example: |
||
121 | * method self second() |
||
122 | * return ['second' => 2, ...]; |
||
123 | * |
||
124 | * @return array |
||
125 | */ |
||
126 | 3 | protected static function overrideIndices(): array |
|
130 | |||
131 | 25 | final protected static function currentEntries(): Entries |
|
144 | |||
145 | 5 | final protected static function createEntries(): Entries |
|
157 | |||
158 | 5 | final protected static function parentEntries(): Entries |
|
166 | } |
||
167 |