| 1 | <?php |
||
| 13 | abstract class Enum |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * Store existing constants in a static cache per object. |
||
| 17 | * |
||
| 18 | * @var array |
||
| 19 | */ |
||
| 20 | private static $cache = []; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Returns instances of the Enum class of all Enum constants |
||
| 24 | * |
||
| 25 | * @return array Constant name in key, Enum instance in value |
||
| 26 | */ |
||
| 27 | 1 | public static function values() |
|
| 31 | |||
| 32 | /** |
||
| 33 | * Returns all possible values as an array |
||
| 34 | * |
||
| 35 | * @return array Constant name in key, constant value in value |
||
| 36 | */ |
||
| 37 | 3 | public static function toArray() |
|
| 47 | |||
| 48 | /** |
||
| 49 | * Check if a value is in enum |
||
| 50 | * |
||
| 51 | * @return boolean True if the value is in enum false if not |
||
| 52 | */ |
||
| 53 | 1 | public static function inEnum($value) |
|
| 59 | } |
||
| 60 |