Sets the value for an encoder option.
@param string $option Name of the option
@param mixed $value Value for the option
@throws InvalidOptionException If the provided encoder option is invalid
497179
public function setOption($option, $value)
    {
        if (!$this->isValidOption($option)) {
            throw new InvalidOptionException(sprintf("Invalid encoder option '%s'", $option));
        }

        $this->options[$option] = $value;
    }
1232259
public function setOption($key, $value)
    {
        if (!in_array($key, array_keys($this->defaultOptions))) {
            throw InvalidOptionException::build([], ['option' => $key]);
        }

        $this->options[$key] = $value;
    }
166345
public static function encode($value, int $options = null) : string
    {
        if ($options) {
            $encoded = json_encode($value, $options);
        } else {
            $encoded = json_encode($value);
        }

        if (!is_string($encoded)) {
            throw new \InvalidArgumentException(sprintf(
                "Json encode failed (%s) with '%s' and type '%s'",
                json_last_error(),
                json_last_error_msg(),
                gettype($encoded)
            ));
        }

        return $encoded;
    }
1142207
protected function setValue($value)
    {
        if (! is_bool($value)) {
            throw InvalidTypeException::fromMessageAndPrototype("Value must be a boolean", static::prototype());
        }

        $this->value = $value;
    }
203880
public function setPosition($value)
    {
        if (!ControlPosition::getIsValid($value)) {
            throw new InvalidConfigException('Unknown "position" value');
        }
        $this->options['position'] = new JsExpression($value);
    }
97759
public function setOption($option)
    {
        if (!isset(static::$availableOptions[$option])) {
            throw new \InvalidArgumentException(sprintf(
                'Invalid option specified: "%s". Expected one of (%s)',
                $option,
                implode(', ', array_keys(static::$availableOptions))
            ));
        }
        if (!in_array(static::$availableOptions[$option], $this->options, true)) {
            $this->options[] = static::$availableOptions[$option];
        }
    }
461000
static function ensureValue($value)
    {
        if (!self::hasValue($value)) {
            throw new InvalidValueException(sprintf(
                'The value %s is not defined in enum class "%s", known values: %s',
                self::dumpValue($value),
                static::class,
                implode(', ', array_map([static::class, 'dumpValue'], self::getValues()))
            ));
        }
    }
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;
    }
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;
    }
1314258
public function setValueAttribute($value)
    {
        if (!$this->isValid($value)) {
            throw new InvalidValueException("The value in the field '" . get_class($this) . "' is invalid");
        }

        $this->attributes['value'] = $this->prepareValue($value);
    }
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);
        }
    }
334781
public function setPath($value)
    {
        if (!SymbolPath::getIsValid($value)) {
            throw new InvalidConfigException('Unknown Symbol Path');
        }
        $this->options['path'] = new JsExpression($value);
    }
45186
public function setOption(string $option, $value) : object
    {
        $this->options[$option] = $value;
        return $this;
    }
316877
public function setIdentifier($value)
    {
        if ($value !== null && ($value < 0 || $value > 0xFFFF)) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Expected an identifier between 0x0000 and 0xFFFF but got %x',
                    $value
                )
            );
        }

        $this->identifier = $value;
    }
961061
public static function assertValidChoice(string $value): void
    {
        if (!isset(static::$choices[$value])) {
            throw new \InvalidArgumentException(\sprintf('Invalid value "%s" for ENUM type "%s".', $value, static::class));
        }
    }
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);
        }
    }
165759
private function setOptionIfNotSet(&$arr, $option, $value)
    {
        if ($this->isOptionSet($arr, $option)) {
            $arr[$option] = $value;
        }
    }