final public static function byValue($value)
    {
        if (!isset(self::$constants[static::class])) {
            self::detectConstants(static::class);
        }

        $name = \array_search($value, self::$constants[static::class], true);
        if ($name === false) {
            throw new InvalidArgumentException(sprintf(
                'Unknown value %s for enumeration %s',
                \is_scalar($value)
                    ? \var_export($value, true)
                    : 'of type ' . (\is_object($value) ? \get_class($value) : \gettype($value)),
                static::class
            ));
        }

        if (!isset(self::$instances[static::class][$name])) {
            self::$instances[static::class][$name] = new static(self::$constants[static::class][$name]);
        }

        return self::$instances[static::class][$name];
    }
final public static function byValue($value)
    {
        if (!isset(self::$constants[static::class])) {
            self::detectConstants(static::class);
        }

        $name = \array_search($value, self::$constants[static::class], true);
        if ($name === false) {
            throw new InvalidArgumentException(sprintf(
                'Unknown value %s for enumeration %s',
                \is_scalar($value)
                    ? \var_export($value, true)
                    : 'of type ' . (\is_object($value) ? \get_class($value) : \gettype($value)),
                static::class
            ));
        }

        if (!isset(self::$instances[static::class][$name])) {
            self::$instances[static::class][$name] = new static(self::$constants[static::class][$name]);
        }

        return self::$instances[static::class][$name];
    }
final public static function byValue ( $ value ) { if ( ! isset ( self :: $ constants [ static :: class ] ) ) { self :: detectConstants ( static :: class ) ; } $ name = \ array_search ( $ value , self :: $ constants [ static :: class ] , true ) ; if ( $ name === false ) { throw new InvalidArgumentException ( sprintf ( 'Unknown value %s for enumeration %s' , \ is_scalar ( $ value ) ? \ var_export ( $ value , true ) : 'of type ' . ( \ is_object ( $ value ) ? \ get_class ( $ value ) : \ gettype ( $ value ) ) , static :: class ) ) ; } if ( ! isset ( self :: $ instances [ static :: class ] [ $ name ] ) ) { self :: $ instances [ static :: class ] [ $ name ] = new static ( self :: $ constants [ static :: class ] [ $ name ] ) ; } return self :: $ instances [ static :: class ] [ $ name ] ; }
Get an enumerator instance by the given value

@param null|bool|int|float|string|array $value Enumerator value
@return static
@throws InvalidArgumentException On an unknwon or invalid value
@throws LogicException           On ambiguous constant values
Get an enumerator instance by the given value