Since: 8.1

interface IntBackedEnum implements BackedEnum (View source)

internal  Internal interface to ensure precise type inference
 

Properties

int $value

Methods

static array
cases()

Generates a list of cases on an enum

from  UnitEnum
static BackedEnum
from(int|string $value)

Translates an 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 an 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.

Return Value

array

An array of all defined cases of this enumeration, in order of declaration.

static BackedEnum from(int|string $value)

Translates an int into the corresponding Enum case, if any. If there is no matching case defined, it will throw a ValueError.

Parameters

int|string $value

The scalar value to map to an enum case.

Return Value

BackedEnum

A case instance of this enumeration.

Exceptions

ValueError

static BackedEnum|null tryFrom(int|string $value)

Translates an int into the corresponding Enum case, if any. If there is no matching case defined, it will return null.

Parameters

int|string $value

The scalar value to map to an enum case.

Return Value

BackedEnum|null

A case instance of this enumeration, or null if not found.