Get an enumerator instance by the constant value

@param null|bool|int|float|string $value The constant value
@return static
@throws \InvalidArgumentException On an invalid or unknown name
@throws \LogicException Not unique constants value
485267
public static function getByValue($value)
    {
        $class = get_called_class();
        $constants = array_flip(static::getConstants());
        if (isset($constants[$value])) {
            return self::$instances[$class][$constants[$value]] = new $class($value);
        } else {
            throw new \InvalidArgumentException('"' . $value . '" not defined');
        }
    }
1162019
public function setValue($value) {
		if (!$this->isPrimitive($value)) {
			throw new \InvalidArgumentException('Use setValue() only for primitives and PhpConstant, anyway use setExpression() instead.');
		}
		$this->value = $value;
		$this->hasValue = true;

		return $this;
	}
349051
final public function equals($value)
    {
        if ($value instanceof Enum) {
            return $this->value == $value->getValue();
        }
        return $this->value == $value;
    }
279244
protected function vaidateValue($value, $element)
    {
        $toTest = $this->getCompareValue();
        if ($this->getCompareAttribute()) {
            $testElement = $element->getParent()->getElement($this->getCompareAttribute());
            if (!$testElement) {
                throw new InvalidArgumentException('Wrong attribute');
            }
            $toTest = $testElement->getValue();
        }
        $return = false;
        switch ($this->getOperator()) {
            case '!=':
                $return = $value != $toTest;
            break;
            case '!==':
                $return = $value !== $toTest;
            break;
            case '>':
                $return = $value > $toTest;
            break;
            case '>=':
                $return = $value >= $toTest;
            break;
            case '<':
                $return = $value < $toTest;
            break;
            case '<=':
                $return = $value <= $toTest;
            break;
            case '===':
                $return = $value === $toTest;
            break;
            case '==':
            default:
                $return = $value == $toTest;
            break;
        }

        return $return;
    }
851826
private static function getClass($value)
    {
        if (\is_object($value)) {
            return new \ReflectionObject($value);
        }

        if (!\is_string($value)) {
            throw new \InvalidArgumentException('Mirror expects an object or class');
        } elseif (!\class_exists($value) && !\interface_exists($value) && !\trait_exists($value)) {
            throw new \InvalidArgumentException('Unknown class or function: ' . $value);
        }

        return new \ReflectionClass($value);
    }
569448
public function coerce($value)
    {
        $enumValue = $this->getValueLookup()[$value];
        return $enumValue ? $enumValue->getName() : NULL;
    }
1338788
public function setValue($value) {
		if(!in_array($value, self::VALID_VALUES)) {
			throw new InvalidArgumentException('Value is not valid.');
		}

		$this->value = $value;

		return $this;
	}
303441
public static function getText($value)
    {
        $enumItem = EnumParser::getInstance()->getEnumItem(static::class, $value);
        if($enumItem)
        {
            return $enumItem->text;
        }
        else
        {
            return null;
        }
    }
620328
public function setValue($value)
    {
        if (!is_string($value) || (is_object($value) && !method_exists($value, "__toString"))) {
            throw new InvalidArgumentException(sprintf(
                "Invalid argument given to %s, expected a string, %s given",
                __METHOD__,
                is_object($value) ? get_class($value) : gettype($value)
            ));
        }

        $value = (string) $value;

        if (null !== $regex = $this->getValidationRegex()) {
            if (! preg_match($regex, $value)) {
                throw new InvalidArgumentException(sprintf(
                    "The given value '%s' doesn't match the validation regular expression: %s",
                    $value,
                    $regex
                ));
            }
        }

        $this->value = $value;

        return $this;
    }
444233
public static function make($value)
    {
        $value = static::prepareValue($value);
        $is_negation = static::parseIsNegation($value);
        list($operator, $value) = static::parseOperatorAndValue($value, $is_negation);

        return new static($operator, $value, $is_negation);
    }
951143
public function normalizeValue($value)
	{
		$className  = $this->getFilterClassName();
		if ($value instanceof $className)
		{
			return $value;
		}

		if (!is_callable($value))
		{
			throw new InvalidArgumentException('Filter ' . var_export($value, true) . ' is neither callable nor an instance of ' . $className);
		}

		return new $className($value);
	}
1105133
public function orx($value)
    {
        if(!is_array($value)) {
            // get arguments 
            $value = func_get_args();
        }
        // Convert all values to 
        $conds = array_map(function($v) {
                if(is_string($v) && $this->getQueryParser()) {
                    return $this->getQueryParser()->parseExpression($v);
                } else if(!$v instanceof Expr\ConditionalExpression) {
                    throw new \InvalidArgumentException('');
                } 
                return $v;
            }, $value);

        //return new Expr\OrX($conds);
        return new Expr\LogicalExpression($conds, Expr\LogicalExpression::TYPE_OR);
    }
1199366
public function removeValue($value): self
    {
        $this->generatorToArray();

        // init
        $isNumericArray = true;

        foreach ($this->getGenerator() as $key => $item) {
            if ($item === $value) {
                if (!\is_int($key)) {
                    $isNumericArray = false;
                }
                unset($this->array[$key]);
            }
        }

        if ($isNumericArray) {
            $this->array = \array_values($this->array);
        }

        return static::create(
            $this->array,
            $this->iteratorClass,
            false
        );
    }
1003687
public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        if (null === $value) {
            return null;
        }

        if (!isset(static::$choices[$value])) {
            throw new \InvalidArgumentException(\sprintf('Invalid value "%s" for ENUM "%s".', $value, $this->getName()));
        }

        return $value;
    }
884531
public static function toUnrestrictedDouble($value)
    {
        if (self::isFloatCastable($value)) {
            return (float)($value instanceof \GMP || is_resource($value) && get_resource_type($value) === 'GMP integer'
                ? gmp_strval($value)
                : $value);
        } else {
            throw new \InvalidArgumentException(ErrorMessageCreator::create($value, 'double (a float)'));
        }
    }
1152932
private function noScalar($value) : Expr
    {
        if (\is_array($value)) {
            return $this->arrayValue($value);
        } elseif (\is_object($value)) {
            return $this->normalizeObject($value);
        }
        throw new InvalidInstance; //@codeCoverageIgnore
    }
1275054
public static function enum(&$value, $options = ['enum'=>[], 'strict'=>false, 'default'=>null])
    {
        if (isset($options['enum']) && is_array($options['enum']) && $options['enum'] != []) {
            $value = in_array($value, $options['enum'], isset($options['strict']) && $options['strict']) ?
                $value : (isset($options['default']) ?
                    $options['default'] : current($options['enum']));
        } else {
            $value = isset($options['default']) ? $options['default'] : null;
        }
        return $value;
    }