Set the value of the Variable.

@param \qtism\common\datatypes\QtiDatatype|null $value A QtiDatatype object or null.
@throws \InvalidArgumentException If the baseType and cardinality of $value are not compliant with the Variable.
559391
public function setValue(QtiDatatype $value = null)
    {
        if (Utils::isBaseTypeCompliant($this->getBaseType(), $value) && Utils::isCardinalityCompliant($this->getCardinality(), $value)) {
            $this->value = $value;
        } else {
            Utils::throwBaseTypeTypingError($this->baseType, $value);
        }
    }
466642
protected function _set($key, $value)
    {
        if (!is_string($key)) {
            throw new Exception\InvalidArgumentException(
                "Key must be a string or a number"
            );
        }
        $this->_viewVars[$key] = $value;
    }
958977
public function setValue($value)
    {
        $this->item->set($this->field->getColName(), $this->field->mmAttribute->widgetToValue($value, null));
    }
704643
public function convertToDatabaseValue($value, AbstractPlatform $platform): int
    {
        \assert('is_int($value)');
        if (!isset($this->getValues()[$value])) {
            throw new \InvalidArgumentException('Invalid type.');
        }
        return $value;
    }
316266
public function setDefaultValue(QtiDatatype $defaultValue = null)
    {
        if (Utils::isBaseTypeCompliant($this->getBaseType(), $defaultValue) && Utils::isCardinalityCompliant($this->getCardinality(), $defaultValue)) {
            $this->defaultValue = $defaultValue;

            return;
        } else {
            Utils::throwBaseTypeTypingError($this->getBaseType(), $defaultValue);
        }
    }
566301
public function setData($keyOrData, $value = null)
    {
        if (is_string($keyOrData) && 0 < strlen($keyOrData)) {
            $this->data[$keyOrData] = $value;
        } elseif(is_array($keyOrData)) {
            $this->data = $keyOrData;
        } else {
            throw new InvalidArgumentException('Expected key/value or array.');
        }

        return $this;
    }
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);
        }
    }
1276940
public function addValue($value)
    {
        if ($this->datatype == 'string') {
            if (is_string($value) == false) {
                throw new InvalidArgumentException('The value(' . $value . ') is not string but the restriction demands it');
            }
        } elseif ($this->datatype == 'integer') {
            // The value comes as string from the wsdl
            if (is_string($value)) {
                $value = intval($value);
            }

            if (is_int($value) == false) {
                throw new InvalidArgumentException('The value(' . $value . ') is not int but the restriction demands it');
            }
        } else {
            if ($value == null) {
                throw new InvalidArgumentException('Value(' . $value . ') is null');
            }
        }

        $this->values[] = $value;
    }
440339
public function setType($value)
    {
        $this->_validateNotNull('Type', $value);
        $this->_validateString('Type', $value);

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

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

        $this->_setModified('type');
    }
140292
public function set($data, $value = null)
    {
        //argument 1 must be an array or string
        Argument::i()->test(1, 'array', 'string');

        if (is_array($data)) {
            $this->data = $data;
            return $this;
        }

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

        return $this;
    }
4952
protected function setTtlOption(?int $value): void
    {
        if (isset($value) && $value < 1) {
            throw new InvalidArgumentException('ttl cant be lower than 1');
        }

        $this->ttl = $value;
    }
524104
public function offsetSet( $offset, $value )
	{
		if( $this instanceof TypeOfInterface && ! $this->typeOf($value, $offset) )
		{
			throw new \InvalidArgumentException("Invalid data type for offset item");
		}

		if (is_null($offset))
		{
			$this->items[] = $value;
		}
		else
		{
			$this->items[$offset] = $value;
		}
	}
1287058
protected function setIdAttr($value)
    {
        if (!is_null($value) && !preg_match('/^[0-9]+$/D', $value)) {
            throw new InvalidIdException('Invalid id: ' . $value);
        }

        $this->id = $value;
    }
139565
public function setValue($value)
    {
        if (null !== $value) {
            if (!$this->validateValue($value)) {
                throw new \InvalidArgumentException(\sprintf(
                    'Binding invalid value (type "%s") into filter "%s" (%s)',
                    \is_object($value) ? \get_class($value) : \gettype($value),
                    $this->name,
                    \get_class($this)
                ));
            }

            $this->value = $value;
            $this->updateBound();
        }

        return $this;
    }
609777
public function setValue($value, $data = null)
    {
        // Save raw value for later validation
        $this->rawValue = $value;

        // Null case
        if (!$value) {
            $this->value = null;
            return $this;
        }

        // Re-run through formatter to tidy up (e.g. remove time component)
        $this->value = $this->tidyInternal($value);
        return $this;
    }
790585
public function setPage($value)
    {
        if ($value === null || $value === '') {
            $this->_page = null;
        } elseif (TypeCast::canCastToString($value)) {
            $this->_page = (string)$value;
        } else {
            throw new InvalidPropertyValueTypeException(
                'Invalid status value in PaymentsRequest', 0, 'PaymentsRequest.page', $value
            );
        }
    }
1077635
protected function setValue($value)
    {
        if (!is_int($value)) {
            throw InvalidTypeException::fromMessageAndPrototype("Value must be an integer", static::prototype());
        }
        $this->value = $value;
    }