BackedEnum
interface BackedEnum implements UnitEnum (View source)
The BackedEnum interface is automatically applied to backed enumerations by the engine. It may not be implemented by user-defined classes. Enumerations may not override its methods, as default implementations are provided by the engine. It is available only for type checks.
Properties
| int|string | $value |
Methods
Translates a string or int into the corresponding Enum
case, if any. If there is no matching case defined, it will throw a
ValueError.
Translates a string or int into the corresponding Enum
case, if any. If there is no matching case defined, it will return null.
Details
static array
cases()
Generates a list of cases on an enum
This method will return a packed array of all cases in an enumeration, in order of declaration.
static BackedEnum
from(int|string $value)
Translates a string or int into the corresponding Enum
case, if any. If there is no matching case defined, it will throw a
ValueError.
static BackedEnum|null
tryFrom(int|string $value)
Translates a string or int into the corresponding Enum
case, if any. If there is no matching case defined, it will return null.