MabeEnum\Enum::getOrdinal PHP Method

getOrdinal() final public method

Get the ordinal number of the enumerator
final public getOrdinal ( ) : integer
return integer
    public final function getOrdinal()
    {
        if ($this->ordinal !== null) {
            return $this->ordinal;
        }
        // detect ordinal
        $ordinal = 0;
        $value = $this->value;
        foreach (self::detectConstants(get_called_class()) as $constValue) {
            if ($value === $constValue) {
                break;
            }
            ++$ordinal;
        }
        $this->ordinal = $ordinal;
        return $ordinal;
    }