本文整理匯總了PHP中qtism\common\utils\Format::isPoint方法的典型用法代碼示例。如果您正苦於以下問題:PHP Format::isPoint方法的具體用法?PHP Format::isPoint怎麽用?PHP Format::isPoint使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類qtism\common\utils\Format
的用法示例。
在下文中一共展示了Format::isPoint方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: stringToDatatype
//.........這裏部分代碼省略.........
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;
case BaseType::POINT:
if (Format::isPoint($string)) {
$parts = explode(" ", $string);
return new Point(intval($parts[0]), intval($parts[1]));
} else {
$msg = "'{$string}' is not valid point.";
throw new UnexpectedValueException($msg);
}
break;
default:
throw new \RuntimeException("Unknown baseType.");
break;
}
} else {
$msg = "BaseType must be a value from the BaseType enumeration.";
throw new InvalidArgumentException($msg);
}
}