コード例 #1
0
ファイル: EqualMarshaller.php プロジェクト: nagyist/qti-sdk
 /**
  * @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;
 }