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


PHP Format::isInteger方法代码示例

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


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

示例1: 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

示例2: unmarshallChildrenKnown

 /**
  * @see \qtism\data\storage\xml\marshalling\OperatorMarshaller::unmarshallChildrenKnown()
  */
 protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children)
 {
     if (($figures = static::getDOMElementAttributeAs($element, 'figures')) !== null) {
         if (Format::isInteger($figures)) {
             $figures = intval($figures);
         }
         $object = new EqualRounded($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:nagyist,项目名称:qti-sdk,代码行数:19,代码来源:EqualRoundedMarshaller.php

示例3: unmarshallChildrenKnown

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

示例4: unmarshall

 /**
  * Unmarshall a DOMElement object corresponding to a printedVariable element.
  * 
  * @param DOMElement $element A DOMElement object.
  * @return QtiComponent A PrintedVariable object.
  * @throws UnmarshallingException
  */
 protected function unmarshall(DOMElement $element)
 {
     if (($identifier = self::getDOMElementAttributeAs($element, 'identifier')) !== null) {
         $component = new PrintedVariable($identifier);
         if (($format = self::getDOMElementAttributeAs($element, 'format')) !== null) {
             $component->setFormat($format);
         }
         if (($powerForm = self::getDOMElementAttributeAs($element, 'powerForm', 'boolean')) !== null) {
             $component->setPowerForm($powerForm);
         }
         if (($base = self::getDOMElementAttributeAs($element, 'base')) !== null) {
             $component->setBase(Format::isInteger($base) === true ? intval($base) : $base);
         }
         if (($index = self::getDOMElementAttributeAs($element, 'index')) !== null) {
             $component->setIndex(Format::isInteger($index) === true ? intval($index) : $base);
         }
         if (($delimiter = self::getDOMElementAttributeAs($element, 'delimiter')) !== null) {
             $component->setDelimiter($delimiter);
         }
         if (($field = self::getDOMElementAttributeAs($element, 'field')) !== null) {
             $component->setField($field);
         }
         if ($mappingIndicator = self::getDOMElementAttributeAs($element, 'mappingIndicator')) {
             $component->setMappingIndicator($mappingIndicator);
         }
         if (($xmlBase = self::getXmlBase($element)) !== false) {
             $component->setXmlBase($xmlBase);
         }
         self::fillBodyElement($component, $element);
         return $component;
     } else {
         $msg = "The mandatory 'identifier' attribute is missing from the 'printedVariable' element.";
         throw new UnmarshallingException($msg, $element);
     }
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:42,代码来源:PrintedVariableMarshaller.php

示例5: unmarshall

 /**
  * Unmarshall a DOMElement object corresponding to an positionObjectInteraction element.
  * 
  * @param DOMElement $element A DOMElement object.
  * @return QtiComponent A PositionObjectInteraction object.
  * @throws UnmarshallingException
  */
 protected function unmarshall(DOMElement $element)
 {
     if (($responseIdentifier = self::getDOMElementAttributeAs($element, 'responseIdentifier')) !== null) {
         $objectElts = self::getChildElementsByTagName($element, 'object');
         if (count($objectElts) > 0) {
             $object = $this->getMarshallerFactory()->createMarshaller($objectElts[0])->unmarshall($objectElts[0]);
             $component = new PositionObjectInteraction($responseIdentifier, $object);
             if (($maxChoices = self::getDOMElementAttributeAs($element, 'maxChoices', 'integer')) !== null) {
                 $component->setMaxChoices($maxChoices);
             }
             if (($minChoices = self::getDOMElementAttributeAs($element, 'minChoices', 'integer')) !== null) {
                 $component->setMinChoices($minChoices);
             }
             if (($centerPoint = self::getDOMElementAttributeAs($element, 'centerPoint')) !== null) {
                 $points = explode(" ", $centerPoint);
                 $pointsCount = count($points);
                 if ($pointsCount === 2) {
                     if (Format::isInteger($points[0]) === true) {
                         if (Format::isInteger($points[1]) === true) {
                             $component->setCenterPoint(new Point(intval($points[0]), intval($points[1])));
                         } else {
                             $msg = "The 2nd integer of the 'centerPoint' attribute value is not a valid integer for element 'positionObjectInteraction'.";
                             throw new UnmarshallingException($msg, $element);
                         }
                     } else {
                         $msg = "The 1st value of the 'centerPoint' attribute value is not a valid integer for element 'positionObjectInteraction'.";
                         throw new UnmarshallingException($msg, $element);
                     }
                 } else {
                     $msg = "The value of the 'centePoint' attribute of a 'positionObjectInteraction' element must be composed of exactly 2 integer values, {$pointsCount} given.";
                     throw new UnmarshallingException($msg, $element);
                 }
             }
             self::fillBodyElement($component, $element);
             return $component;
         } else {
             $msg = "A 'positionObjectInteraction' element must contain exactly one 'object' element, none given.";
             throw new UnmarshallingException($msg, $element);
         }
     } else {
         $msg = "The mandatory 'responseIdentifier' attribute is missing from the 'positionObjectInteraction' object.";
         throw new UnmarshallingException($msg, $element);
     }
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:51,代码来源:PositionObjectInteractionMarshaller.php

示例6: stringToDatatype

 /**
  * Transform a string representing a QTI valueType value in a
  * the correct datatype.
  *
  * @param string $string The QTI valueType value as a string.
  * @param integer $baseType The QTI baseType that defines the datatype of $string.
  * @return mixed A converted object/primitive type.
  * @throws \InvalidArgumentException If $baseType is not a value from the BaseType enumeration.
  * @throws \UnexpectedValueException If $string cannot be transformed in a Value expression with the given $baseType.
  */
 public static function stringToDatatype($string, $baseType)
 {
     if (in_array($baseType, BaseType::asArray())) {
         $value = null;
         switch ($baseType) {
             case BaseType::BOOLEAN:
                 if (Format::isBoolean($string)) {
                     $value = Format::toLowerTrim($string) == 'true' ? true : false;
                     return $value;
                 } else {
                     $msg = "'{$string}' cannot be transformed into boolean.";
                     throw new UnexpectedValueException($msg);
                 }
                 break;
             case BaseType::INTEGER:
                 if (Format::isInteger($string)) {
                     $value = intval($string);
                     return $value;
                 } else {
                     $msg = "'{$string}' cannot be transformed into integer.";
                     throw new UnexpectedValueException($msg);
                 }
                 break;
             case BaseType::FLOAT:
                 if (Format::isFloat($string)) {
                     $value = floatval($string);
                     return $value;
                 } else {
                     $msg = "'{$string}' cannot be transformed into float.";
                     throw new UnexpectedValueException($msg);
                 }
                 break;
             case BaseType::URI:
                 if (Format::isUri($string)) {
                     return $string;
                 } else {
                     $msg = "'{$string}' is not a valid URI.";
                     throw new UnexpectedValueException($msg);
                 }
                 break;
             case BaseType::IDENTIFIER:
                 if (Format::isIdentifier($string)) {
                     return $string;
                 } else {
                     $msg = "'{$string}' is not a valid QTI Identifier.";
                     throw new UnexpectedValueException($msg);
                 }
                 break;
             case BaseType::INT_OR_IDENTIFIER:
                 if (Format::isIdentifier($string)) {
                     return $string;
                 } elseif (Format::isInteger($string)) {
                     return intval($string);
                 } else {
                     $msg = "'{$string}' is not a valid QTI Identifier nor a valid integer.";
                     throw new UnexpectedValueException($msg);
                 }
                 break;
             case BaseType::PAIR:
                 if (Format::isPair($string)) {
                     $pair = explode(" ", $string);
                     return new Pair($pair[0], $pair[1]);
                 } else {
                     $msg = "'{$string}' is not a valid pair.";
                     throw new UnexpectedValueException($msg);
                 }
                 break;
             case BaseType::DIRECTED_PAIR:
                 if (Format::isDirectedPair($string)) {
                     $pair = explode(" ", $string);
                     return new DirectedPair($pair[0], $pair[1]);
                 } else {
                     $msg = "'{$string}' is not a valid directed pair.";
                     throw new UnexpectedValueException($msg);
                 }
                 break;
             case BaseType::DURATION:
                 if (Format::isDuration($string)) {
                     return new Duration($string);
                 } else {
                     $msg = "'{$string}' is not a valid duration.";
                     throw new UnexpectedValueException($msg);
                 }
                 break;
             case BaseType::FILE:
                 throw new \RuntimeException("Unsupported baseType: file.");
                 break;
             case BaseType::STRING:
                 return '' . $string;
                 break;
//.........这里部分代码省略.........
开发者ID:hutnikau,项目名称:qti-sdk,代码行数:101,代码来源:Utils.php


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