当前位置: 首页>>代码示例>>PHP>>正文


PHP utils\Format类代码示例

本文整理汇总了PHP中qtism\common\utils\Format的典型用法代码示例。如果您正苦于以下问题:PHP Format类的具体用法?PHP Format怎么用?PHP Format使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Format类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: unmarshallChildrenKnown

 /**
  * @see \qtism\data\storage\xml\marshalling\OperatorMarshaller::unmarshallChildrenKnown()
  */
 protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children)
 {
     $object = new Equal($children);
     if (($toleranceMode = static::getDOMElementAttributeAs($element, 'toleranceMode')) !== null) {
         $toleranceMode = ToleranceMode::getConstantByName($toleranceMode);
         $object->setToleranceMode($toleranceMode);
     }
     if (($tolerance = static::getDOMElementAttributeAs($element, 'tolerance')) !== null) {
         $tolerance = explode(" ", $tolerance);
         if (count($tolerance) < 1) {
             $msg = "No 'tolerance' could be extracted from element '" . $element->localName . "'.";
             throw new UnmarshallingException($msg, $element);
         } elseif (count($tolerance) > 2) {
             $msg = "'tolerance' attribute not correctly formatted in element '" . $element->localName . "'.";
             throw new UnmarshallingException($msg, $element);
         } else {
             $finalTolerance = array();
             foreach ($tolerance as $t) {
                 $finalTolerance[] = Format::isFloat($t) ? floatval($t) : $t;
             }
             $object->setTolerance($finalTolerance);
         }
     }
     if (($includeLowerBound = static::getDOMElementAttributeAs($element, 'includeLowerBound', 'boolean')) !== null) {
         $object->setIncludeLowerBound($includeLowerBound);
     }
     if (($includeUpperBound = static::getDOMElementAttributeAs($element, 'includeUpperBound', 'boolean')) !== null) {
         $object->setIncludeUpperBound($includeUpperBound);
     }
     return $object;
 }
开发者ID:nagyist,项目名称:qti-sdk,代码行数:34,代码来源:EqualMarshaller.php

示例2: unmarshall

 /**
  * Unmarshall a DOMElement object corresponding to a QTI weight element.
  * 
  * @param DOMElement $element A DOMElement object.
  * @return QtiComponent A Weight object.
  * @throws UnmarshallingException If the mandatory attributes 'identifier' or 'value' are missing from $element but also if 'value' cannot be converted to a float value or 'identifier' is not a valid QTI Identifier.
  */
 protected function unmarshall(DOMElement $element)
 {
     // identifier is a mandatory value.
     if (($identifier = static::getDOMElementAttributeAs($element, 'identifier', 'string')) !== null) {
         if (($value = static::getDOMElementAttributeAs($element, 'value', 'string')) !== null) {
             if (Format::isFloat($value)) {
                 try {
                     $object = new Weight($identifier, floatval($value));
                     return $object;
                 } catch (InvalidArgumentException $e) {
                     $msg = "The value of 'identifier' from element '" . $element->localName . "' is not a valid QTI Identifier.";
                     throw new UnmarshallingException($msg, $element, $e);
                 }
             } else {
                 $msg = "The value of attribute 'value' from element '" . $element->localName . "' cannot be converted into a float.";
                 throw new UnmarshallingException($msg, $element);
             }
         } else {
             $msg = "The mandatory attribute 'value' is missing from element '" . $element->localName . "'.";
             throw new UnmarshallingException($msg, $element);
         }
     } else {
         $msg = "The mandatory attribute 'identifier' is missing from element '" . $element->localName . "'.";
         throw new UnmarshallingException($msg, $element);
     }
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:33,代码来源:WeightMarshaller.php

示例3: setCite

 /**
  * Set the cite attribute's value.
  *
  * @param string $cite
  * @throws \InvalidArgumentException If $cite is not a valid URI.
  */
 public function setCite($cite)
 {
     if (Format::isUri($cite) === true) {
     } else {
         $msg = "The 'cite' argument must be a valid URI, '" . $cite . "' given.";
         throw new InvalidArgumentException($msg);
     }
 }
开发者ID:nagyist,项目名称:qti-sdk,代码行数:14,代码来源:Q.php

示例4: setHref

 /**
  * Set the href attribute.
  * 
  * @param string $href A URI (Uniform Resource Identifier).
  * @throws InvalidArgumentException If $href is not a URI.
  */
 public function setHref($href)
 {
     if (Format::isUri($href) === true) {
         $this->href = $href;
     } else {
         $msg = "The 'href' argument must be a URI, '" . $href . "' given.";
         throw new InvalidArgumentException($msg);
     }
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:15,代码来源:A.php

示例5: 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);
     }
 }
开发者ID:nagyist,项目名称:qti-sdk,代码行数:15,代码来源:Repeat.php

示例6: setIdentifier

 /**
  * Set the identifier of the template variable to be set.
  * 
  * @param string $identifier A valid QTI identifier.
  */
 public function setIdentifier($identifier)
 {
     if (Format::isIdentifier($identifier, false) === true) {
         $this->identifier = $identifier;
     } else {
         $msg = "The 'identifier' argument must be a valid QTI identifier, '" . $identifier . "' given.";
         throw new InvalidArgumentException($msg);
     }
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:14,代码来源:SetTemplateValue.php

示例7: setSectionIdentifier

 /**
  * Set the assessment section identifier to match.
  *
  * @param string $sectionIdentifier A QTI Identifier.
  * @throws \InvalidArgumentException If $sectionIdentifier is not a valid QTI Identifier.
  */
 public function setSectionIdentifier($sectionIdentifier)
 {
     if (Format::isIdentifier($sectionIdentifier) || empty($sectionIdentifier)) {
         $this->sectionIdentifier = $sectionIdentifier;
     } else {
         $msg = "'{$sectionIndentifier}' is not a valid QTI Identifier.";
         throw new InvalidArgumentException($msg);
     }
 }
开发者ID:nagyist,项目名称:qti-sdk,代码行数:15,代码来源:ItemSubset.php

示例8: setXmlBase

 /**
  * @see \qtism\data\content\Flow::setXmlBase()
  */
 public function setXmlBase($xmlBase = '')
 {
     if (is_string($xmlBase) && (empty($xmlBase) || Format::isUri($xmlBase))) {
         $this->xmlBase = $xmlBase;
     } else {
         $msg = "The 'xmlBase' argument must be an empty string or a valid URI, '" . $xmlBase . "' given";
         throw new InvalidArgumentException($msg);
     }
 }
开发者ID:nagyist,项目名称:qti-sdk,代码行数:12,代码来源:XInclude.php

示例9: setFieldIdentifier

 /**
  * Set the fieldIdentifier attribute.
  * 
  * @param string $fieldIdentifier A QTI Identifier.
  * @throws InvalidArgumentException If $fieldIdentifier is not a valid QTI Identifier.
  */
 public function setFieldIdentifier($fieldIdentifier)
 {
     if (Format::isIdentifier($fieldIdentifier)) {
         $this->fieldIdentifier = $fieldIdentifier;
     } else {
         $msg = "'{$fieldIdentifier}' is not a valid QTI Identifier.";
         throw new InvalidArgumentException($msg);
     }
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:15,代码来源:FieldValue.php

示例10: 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);
     }
 }
开发者ID:nagyist,项目名称:qti-sdk,代码行数:15,代码来源:Index.php

示例11: setIdentifier

 /**
  * Set the identifier of the associated mapping.
  *
  * @param string $identifier A QTI Identifier.
  * @throws \InvalidArgumentException If $identifier is not a valid QTI Identifier.
  */
 public function setIdentifier($identifier)
 {
     if (Format::isIdentifier($identifier, false)) {
         $this->identifier = $identifier;
     } else {
         $msg = "{$identifier} is not a valid QTI Identifier.";
         throw new InvalidArgumentException($identifier);
     }
 }
开发者ID:nagyist,项目名称:qti-sdk,代码行数:15,代码来源:MapResponse.php

示例12: checkType

 /**
  * Check if $value is a valid QTI Identifier.
  *
  * @throws \InvalidArgumentException If $value is not a valid QTI Identifier.
  */
 protected function checkType($value)
 {
     if (gettype($value) !== 'string') {
         $msg = "IdentifierCollection class only accept string values, '" . gettype($value) . "' given.";
         throw new InvalidArgumentException($msg);
     } elseif (!Format::isIdentifier($value)) {
         $msg = "IdentifierCollection class only accept valid QTI Identifiers, '{$value}' given.";
         throw new InvalidArgumentException($msg);
     }
 }
开发者ID:nagyist,项目名称:qti-sdk,代码行数:15,代码来源:IdentifierCollection.php

示例13: unmarshallChildrenKnown

 /**
  * Unmarshall a QTI repeat operator element into a Repeat object.
  *
  * @param DOMElement The repeat element to unmarshall.
  * @param QtiComponentCollection A collection containing the child Expression objects composing the Operator.
  * @return QtiComponent A Repeat object.
  * @throws UnmarshallingException
  */
 protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children)
 {
     if (($numberRepeats = static::getDOMElementAttributeAs($element, 'numberRepeats')) !== null) {
         if (Format::isInteger($numberRepeats)) {
             $numberRepeats = intval($numberRepeats);
         }
         $object = new Repeat($children, $numberRepeats);
         return $object;
     } else {
         $msg = "The mandatory attribute 'numberRepeats' is missing from element '" . $element->localName . "'.";
         throw new UnmarshallingException($msg, $element);
     }
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:21,代码来源:RepeatMarshaller.php

示例14: 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);
     }
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:24,代码来源:RoundToMarshaller.php

示例15: 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);
     }
 }
开发者ID:nagyist,项目名称:qti-sdk,代码行数:23,代码来源:RandomFloatMarshaller.php


注:本文中的qtism\common\utils\Format类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。