/** * Set the default value of the Variable. * * @param \qtism\common\datatypes\QtiDatatype|null $defaultValue A QtiDatatype object or null. * @throws \InvalidArgumentException If $defaultValue's type is not compliant with the qti:baseType of the Variable. */ 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); } }
protected function checkType($value) { parent::checkType($value); if (!Utils::isBaseTypeCompliant($this->getBaseType(), $value)) { Utils::throwBaseTypeTypingError($this->getBaseType(), $value); } }