本文整理汇总了PHP中qtism\common\utils\Format::isVariableRef方法的典型用法代码示例。如果您正苦于以下问题:PHP Format::isVariableRef方法的具体用法?PHP Format::isVariableRef怎么用?PHP Format::isVariableRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtism\common\utils\Format
的用法示例。
在下文中一共展示了Format::isVariableRef方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setNumberRepeats
/**
* Set the numberRepeats attribute.
*
* @param integer|string $numberRepeats An integer or a QTI variable reference.
* @throws \InvalidArgumentException If $numberRepeats is not an integer nor a valid QTI variable reference.
*/
public function setNumberRepeats($numberRepeats)
{
if (is_int($numberRepeats) || gettype($numberRepeats) === 'string' && Format::isVariableRef($numberRepeats)) {
$this->numberRepeats = $numberRepeats;
} else {
$msg = "The numberRepeats argument must be an integer or a variable reference, '" . gettype($numberRepeats) . "' given.";
throw new InvalidArgumentException($msg);
}
}
示例2: setN
/**
* Set the n attribute.
*
* @param integer|string $n The index to lookup. It must be an integer or a variable reference.
* @throws \InvalidArgumentException If $n is not an integer nor a variable reference.
*/
public function setN($n)
{
if (is_int($n) || gettype($n) === 'string' && Format::isVariableRef($n)) {
$this->n = $n;
} else {
$msg = "The n attribute must be an integer or a variable reference, '" . gettype($n) . "' given.";
throw new InvalidArgumentException($msg);
}
}
示例3: unmarshall
/**
* Unmarshall a DOMElement object corresponding to a QTI randomFloat element.
*
* @param \DOMElement $element A DOMElement object.
* @return \qtism\data\QtiComponent A RandomFloat object.
* @throws \qtism\data\storage\xml\marshalling\UnmarshallingException If the mandatory attributes min or max ar missing.
*/
protected function unmarshall(DOMElement $element)
{
// max attribute is mandatory.
if (($max = static::getDOMElementAttributeAs($element, 'max')) !== null) {
$max = Format::isVariableRef($max) ? $max : floatval($max);
$object = new RandomFloat(0.0, $max);
if (($min = static::getDOMElementAttributeAs($element, 'min')) !== null) {
$min = Format::isVariableRef($min) ? $min : floatval($min);
$object->setMin($min);
}
return $object;
} else {
$msg = "The mandatory attribute 'max' is missing from element '" . $element->localName . "'.";
throw new UnmarshallingException($msg, $element);
}
}
示例4: unmarshallChildrenKnown
/**
* Unmarshall a QTI roundTo operator element into a RoundTo object.
*
* @param DOMElement The roundTo element to unmarshall.
* @param QtiComponentCollection A collection containing the child Expression objects composing the Operator.
* @return QtiComponent A RoundTo object.
* @throws UnmarshallingException
*/
protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children)
{
if (($figures = static::getDOMElementAttributeAs($element, 'figures', 'string')) !== null) {
if (!Format::isVariableRef($figures)) {
$figures = intval($figures);
}
$object = new RoundTo($children, $figures);
if (($roundingMode = static::getDOMElementAttributeAs($element, 'roundingMode')) !== null) {
$object->setRoundingMode(RoundingMode::getConstantByName($roundingMode));
}
return $object;
} else {
$msg = "The mandatory attribute 'figures' is missing from element '" . $element->localName . "'.";
throw new UnmarshallingException($msg, $element);
}
}
示例5: unmarshall
/**
* Unmarshall a DOMElement object corresponding to a QTI randomInteger element.
*
* @param DOMElement $element A DOMElement object.
* @return QtiComponent A RandomInteger object.
* @throws UnmarshallingException If the mandatory attributes 'min' or 'max' are missing from $element.
*/
protected function unmarshall(DOMElement $element)
{
if (($max = static::getDOMElementAttributeAs($element, 'max', 'string')) !== null) {
$max = Format::isVariableRef($max) ? $max : intval($max);
$object = new RandomInteger(0, $max);
if (($step = static::getDOMElementAttributeAs($element, 'step')) !== null) {
$object->setStep(abs(intval($step)));
}
if (($min = static::getDOMElementAttributeAs($element, 'min')) !== null) {
$min = Format::isVariableRef($min) ? $min : intval($min);
$object->setMin($min);
}
return $object;
} else {
$msg = "The mandatory attribute 'max' is missing from element '" . $element->localName . "'.";
throw new UnmarshallingException($msg, $element);
}
}
示例6: setMax
/**
* Set the value of the max attribute.
*
* @param integer $max
* @throws \InvalidArgumentException
*/
public function setMax($max)
{
if (is_int($max) || Format::isVariableRef($max)) {
$this->max = $max;
} else {
$msg = "'Max' must be an integer, '" . gettype($max) . "' given.";
throw new InvalidArgumentException($msg);
}
}
示例7: setIndex
/**
* Set the index to use when displaying a variable of ordered cardinality. Give a negative integer
* if there is no index indicated.
*
* @param integer|string $index An integer or variable reference.
* @throws InvalidArgumentException If $index is not an integer nor a variable reference.
*/
public function setIndex($index)
{
if (is_int($index) === true || Format::isVariableRef($index) === true) {
$this->index = $index;
} else {
$msg = "The 'index' argument must be an integer or a variable reference, '" . $index . "' given.";
throw new InvalidArgumentException($msg);
}
}
示例8: setFigures
/**
* Set the number of figures to round to.
*
* @param integer|string $figures An integer value or a variable reference.
* @throws InvalidArgumentException If $figures is not an integer nor a variable reference.
*/
public function setFigures($figures)
{
if (is_int($figures) || gettype($figures) === 'string' && Format::isVariableRef($figures)) {
$this->figures = $figures;
} else {
$msg = "The figures argument must be an integer or a variable reference, '" . $figures . "' given.";
throw new InvalidArgumentException($msg);
}
}
示例9: testInvalidVariableRefFormat
/**
* @dataProvider invalidVariableRefFormatProvider
*/
public function testInvalidVariableRefFormat($string)
{
$this->assertFalse(Format::isVariableRef($string));
}
示例10: setMax
/**
* Set the max attribute.
*
* @param number|string $max A numeric value or a variableRef.
* @throws \InvalidArgumentException If $max is not a numeric value nor a variableRef.
*/
public function setMax($max)
{
if (is_numeric($max) || Format::isVariableRef($max)) {
$this->max = $max;
} else {
$msg = "'Max must be a numeric value or a variableRef, '" . gettype($max) . "' given.";
throw new InvalidArgumentException($msg);
}
}
示例11: setMax
/**
* Set the max attribute.
*
* @param string|integer $max An integer or a variable reference.
* @throws \InvalidArgumentException If $max is not an integer nor a variable reference.
*/
public function setMax($max)
{
if (is_int($max) || gettype($max) === 'string' && Format::isVariableRef($max)) {
$this->max = $max;
} else {
$msg = "The max attribute must be an integer or a variable reference, '" . $max . "' given.";
throw new InvalidArgumentException($msg);
}
}