Creates the enum by value
@param string $value
@return Enum
@throws \InvalidArgumentException
545263
static function ByValue($value)
    {
        $calledClass = get_called_class();
        $allowed = self::AllowedClassValues($calledClass);
        if (!in_array($value, $allowed, true))
            throw new \InvalidArgumentException('Value ' . $value . ' not allowed for enum ' . $calledClass);
        
        return new $calledClass($value);
    }
1070024
public function setValue($name, $value) {
		if (substr($name, -1) === '_') {
			throw new InvalidArgumentException('$name cannot end with "_"');
		}
		$this->remove($name);
		$this->{$name} = $value;
		return $this;
	}
1164945
protected function setValue($value)
    {
        if (is_string($value)) {
            $value = trim($value);
            if ($value !== "") {
                $this->value = $value;
            } else {
                throw new \InvalidArgumentException("Invalid value for argument 'value' given.");
            }
        } else {
            throw new \InvalidArgumentException(
                "Invalid type '" . gettype($value) . "' for argument 'value' given. String expected."
            );
        }

        return $this;
    }
308771
public function enum($model, $key = null, $value = null) {
        $alias = is_string($model) ? $model : $model->alias;

        if (!isset($this->_enums[$alias])) {
            throw new InvalidArgumentException(sprintf('%s::$enum does not exist', $alias));
        }

        $enum = $this->_enums[$alias];

        if ($key) {
            if (!isset($enum[$key])) {
                throw new OutOfBoundsException(sprintf('Field %s does not exist within %s::$enum', $key, $model->alias));
            }

            if ($value !== null) {
                return isset($enum[$key][$value]) ? $enum[$key][$value] : null;
            } else {
                return $enum[$key];
            }
        }

        return $enum;
    }
316061
public function normalizeValue($value)
	{
		if ($value instanceof AttributeFilter)
		{
			return $value;
		}

		if (is_callable($value))
		{
			return new AttributeFilter($value);
		}

		throw new InvalidArgumentException('Argument 1 passed to ' . __METHOD__ . ' must be a valid callback or an instance of s9e\\TextFormatter\\Configurator\\Items\\AttributeFilter');
	}
710650
public function setValue($value)
    {
        if (is_string($value) === true) {
            $this->value = $value;
        } else {
            $msg = "The 'value' argument must be a string, '" . gettype($value) . "' given.";
            throw new InvalidArgumentException($msg);
        }
    }
8369
protected function encode($value)
    {
        try {
            return $this->encoders->getEncoderForValue($value)
                ->encode($value, new EncodingContext());
        } catch (EncodingException | InvalidArgumentException | OutOfBoundsException $ex) {
            throw new SerializationException('Failed to serialize value', 0, $ex);
        }
    }
103635
public static function enum($value, $options){

		$value = static::_nullValue($value);

		if(!in_array($value, $options)){

			return null;
		}

		return $value;
	}
1118752
public function format($value)
    {
        if (!$this->validate($value))
            throw new \InvalidArgumentException("`{$value}` is not a valid HTTP URI");

        $url = Http::createFromString($value);

        if ($url->getScheme() == '') {
            $url = $url->withScheme('http');
        }

        return (String)$url;
    }
502662
public function serialize($value) : string
    {
        if (!is_int($value)) {
            throw InvalidValueException::valueDoesNotMatchType($this, $value);
        }

        return (string) $value;
    }
249115
public function toPlatformValue($value)
    {
        if (!is_array($this->getExtra()) || !in_array($value, $this->getExtra())) {
            throw new BadArgumentException(sprintf('Enumeration type error. Allowed only (%s)', implode(', ', $this->getExtra())));
        }
        
        return parent::toPlatformValue($value);
    }
1283129
public static function get($value): self
    {
        $class = get_called_class();

        if ($value instanceof self) {
            $value = $value->value();
        }

        if (!static::has($value)) {
            throw EnumException::invalidEnumValue($class, $value);
        }

        return static::all()[$value];
    }
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;
    }
284815
public static function fromNative($value)
    {
        $str = (string) $value;
        if (empty($str)) {
            throw new InvalidArgumentException(
                'Refusing to create a DeltaId from an empty string or any other type of value that casts into an ' .
                'empty string.'
            );
        }

        return new static(hash(self::HASH_ALGORITHM, $str));
    }
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');
        }
    }
603687
public function setColorLightness($value)
    {
        if (!is_array($value) ||
            !array_key_exists(0, $value) ||
            !array_key_exists(1, $value) ||
            !is_numeric($value[0]) ||
            !is_numeric($value[1]) ||
            $value[0] < 0 || $value[0] > 1 ||
            $value[1] < 0 || $value[1] > 1
        ) {
            throw new \InvalidArgumentException(
                "The value passed to setColorLightness was invalid. ".
                "Please check the documentation.");
        }
        
        $this->colorLightness = array((float)$value[0], (float)$value[1]);
        return $this;
    }
56131
private function internalSetValue($value)
    {
        if (is_float($value)) {
            $valueToSet = Utils::convertExponentialToString($value);
        } else {
            $valueToSet = (string)$value;
        }

        if (!is_numeric($valueToSet)) {
            throw new InvalidArgumentException('Invalid number provided: ' . $valueToSet);
        }

        // We use a slick trick to make sure the scale is respected.
        $this->value = bcadd(0, $valueToSet, $this->getScale());

        return $this;
    }