@param string $value

@throws \Kerox\Messenger\Exception\InvalidCurrencyException
556740
protected function isValidCurrency(string $value): void
    {
        $allowedCurrency = $this->getAllowedCurrency();

        $regex = '/^' . implode('|', $allowedCurrency) . '$/';
        if (!preg_match($regex, $value)) {
            throw new InvalidCurrencyException(sprintf(
                '%s is not a valid currency. Currency must be in ISO-4217-3 format.',
                $value
            ));
        }
    }
762959
public function setCommitMessage($value)
    {
        $this->_validateString('CommitMessage', $value);

        if ($this->data['commit_message'] === $value) {
            return;
        }

        $this->data['commit_message'] = $value;

        $this->_setModified('commit_message');
    }
1284114
protected function guard($value)
    {
        if (!is_int($value)) {
            throw new InvalidTcpPortException($value);
        }

        if ($value < 0 || $value > 65535) {
            throw new InvalidTcpPortException($value);
        }
    }
1142207
protected function setValue($value)
    {
        if (! is_bool($value)) {
            throw InvalidTypeException::fromMessageAndPrototype("Value must be a boolean", static::prototype());
        }

        $this->value = $value;
    }
94006
protected function onSetFormValue(string $value): void
    {
        foreach ($this->options as $option) {
            $isMatch = ($value === $option->getValue());
            $option->setSelected($isMatch);

            if ($isMatch) {
                $this->value = $value;
            }
        }

        parent::onSetFormValue($value);
    }
1225564
public function setPaymentMethodData($value)
    {
        if ($value === null || $value === '') {
            $this->_paymentMethodData = null;
        } elseif (is_object($value) && $value instanceof AbstractPaymentData) {
            $this->_paymentMethodData = $value;
        } else {
            throw new InvalidPropertyValueTypeException(
                'Invalid paymentMethodData value type in CreatePaymentRequest',
                0,
                'CreatePaymentRequest.paymentMethodData',
                $value
            );
        }
    }
1292024
public function setValue($value) {
        if ($value !== null) {
            if ($this->isIncremental() && ! is_numeric($value)) {
                throw new InvalidOptionValueException(s(
                    'Trying to set a non numeric value "%s" on incremental option "%s".',
                    get_type($value),
                    $this->getNameOrAlias()
                ));
            }

            if ($this->isBoolean() && ! is_bool($value)) {
                throw new InvalidOptionValueException(s(
                    'Trying to set a non boolean value "%s" on boolean option "%s".',
                    get_type($value),
                    $this->getNameOrAlias()
                ));
            }

            if ($this->isSingle() && ! is_scalar($value)) {
                throw new InvalidOptionValueException(s(
                    'Trying to set a non scalar value "%s" on option "%s" ' .
                    'that expects one scalar value.',
                    get_type($value),
                    $this->getNameOrAlias()
                ));
            }

            if ($this->isMultiple() && ! is_array($value)) {
                throw new InvalidOptionValueException(s(
                    'Trying to set a non array value "%s" on option "%s" ' .
                    'that expects multiple values.',
                    get_type($value),
                    $this->getNameOrAlias()
                ));
            }
        }

        $this->value = $value;

        return $this;
    }
640652
public function onSessionInit($value) {
        if(!$value->offsetExists("value")) {
            return;
        }

        $value = $value->offsetGet("value");

        foreach($this->getFormElements() as $name => $child) {
            if(!$value->offsetExists($name)) continue;

            $newvalue = $value->offsetGet($name);

            $child->setValue($newvalue);

            //check if child did some processing/initializing on object values - keep sync

            $childvalue = $child->getValue();

            if($newvalue !== $childvalue) {
                $value->offsetSet($name, $childvalue);
            }
        }
    }
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;
    }
862629
public static function isNullOrCallable($value, $message = null)
    {
        if (!is_null($value) && !is_callable($value)) {
            throw new InvalidArgumentException(sprintf(
                $message ?: 'Expected null or callable, but got %s',
                Helper::typeToString($value)
            ));
        }
    }
73504
public function setSenderId($value)
    {
        if (is_numeric($value)) {
            if (strlen($value) <= self::SENDER_ID_NUMERIC_MAX) {
                $this->senderId = $value;
            } else {
                throw new \Exception('The sender ID is too long (' . self::SENDER_ID_NUMERIC_MAX . ' Max.).');
            }
        } elseif (ctype_alnum($value)) {
            if (strlen($value) <= self::SENDER_ID_ALPHANUMERIC_MAX) {
                $this->senderId = $value;
            } else {
                throw new \Exception('The sender ID is too long (' . self::SENDER_ID_ALPHANUMERIC_MAX . ' Max.).');
            }
        } else {
            throw new \Exception('The sender ID is not a numeric of alphanumeric.');
        }
        return $this;
    }
1362174
public function checkValue(&$value)
    {
        if (is_string($value)) {
            $value = Placeholder::replaceStringsAndComments($value);
            $value = Placeholder::removeCommentPlaceholders($value, true);
            $value = Placeholder::replaceStringPlaceholders($value, true);
            $value = trim($value);

            if ($value !== '') {
                return true;
            } else {
                $this->setIsValid(false);
            }
        } else {
            throw new \InvalidArgumentException(
                "Invalid type '" . gettype($value). "' for argument 'value' given."
            );
        }
    }
91537
public function consumeAnnotationToken(string $value): void
    {
        if ($this->currentAnnotation === null) {
            // We are not in an annotation, build a new one.
            $this->currentAnnotation = $this->annotationFactory
                ->invoke($value, $this->currentLine);
        } else {
            if ($this->currentAnnotationContent === null) {
                // It is an annotation without content, save it and create the new one.
                $this->parsedAnnotations[] = $this->currentAnnotation;
                $this->reset();
                $this->currentAnnotation = $this->annotationFactory
                    ->invoke($value, $this->currentLine);
            } else {
                // An annotation content parsing is not finished.
                throw new AnnotationParseException(
                    'An annotation content is not closed (you probably forget to close a parenthesis or a quote)'
                );
            }
        }
    }
1057496
public function set($key, $value)
    {
        if (!$value instanceof Contact) {
            throw new InvalidArgumentException(
                sprintf(
                    '%s only accepts instances of %s. Tried to to set key %s.',
                    __FUNCTION__, Contact::class, $key
                )
            );
        }

        parent::set($key, $value);
    }
932
public function checkValue(&$value)
    {
        if (is_string($value)) {
            $value = Placeholder::replaceStringsAndComments($value);
            $value = Placeholder::removeCommentPlaceholders($value, true);
            $value = preg_replace('/[ ]+/', ' ', $value);
            $value = Placeholder::replaceStringPlaceholders($value, true);

            return true;
        } else {
            throw new \InvalidArgumentException(
                "Invalid type '" . gettype($value). "' for argument 'value' given."
            );
        }
    }
1287058
protected function setIdAttr($value)
    {
        if (!is_null($value) && !preg_match('/^[0-9]+$/D', $value)) {
            throw new InvalidIdException('Invalid id: ' . $value);
        }

        $this->id = $value;
    }
479127
public function setReason($value)
    {
        if ($value === null || $value === '') {
            throw new EmptyPropertyValueException('Empty reason value', 0, 'cancellation_details.reason');
        }
        if (TypeCast::canCastToEnumString($value)) {
            $value = strtolower((string)$value);
            if (CancellationDetailsReasonCode::valueExists($value)) {
                $this->_reason = $value;
            } else {
                throw new InvalidPropertyValueException(
                    'Invalid reason value: "'.$value.'"', 0, 'cancellation_details.reason', $value
                );
            }
        } else {
            throw new InvalidPropertyValueTypeException('Invalid reason value type', 0, 'cancellation_details.reason',
                $value);
        }
    }