final public static function fromOrdinal(int $ordinal): Enum
    {
        $constants = self::getMembers();
        $item = array_slice($constants, $ordinal, 1, true);

        if (!$item) {
            $end = count($constants) - 1;
            $message = sprintf('Enum ordinal (%d) out of range [0, %d]', $ordinal, $end);
            throw new DomainException($message);
        }

        return new static(current($item));
    }
final public static function fromOrdinal(int $ordinal): Enum
    {
        $constants = self::getMembers();
        $item = array_slice($constants, $ordinal, 1, true);

        if (!$item) {
            $end = count($constants) - 1;
            $message = sprintf('Enum ordinal (%d) out of range [0, %d]', $ordinal, $end);
            throw new DomainException($message);
        }

        return new static(current($item));
    }
final public static function fromOrdinal ( int $ ordinal ) : Enum { $ constants = self :: getMembers ( ) ; $ item = array_slice ( $ constants , $ ordinal , 1 , true ) ; if ( ! $ item ) { $ end = count ( $ constants ) - 1 ; $ message = sprintf ( 'Enum ordinal (%d) out of range [0, %d]' , $ ordinal , $ end ) ; throw new DomainException ( $ message ) ; } return new static ( current ( $ item ) ) ; }
Creates instance from an enum ordinal position

@param int $ordinal The enum ordinal position

@return Enum

@throws DomainException When the ordinal is invalid
Creates instance from an enum ordinal position