本文整理汇总了PHP中qtism\common\utils\Format::isCoords方法的典型用法代码示例。如果您正苦于以下问题:PHP Format::isCoords方法的具体用法?PHP Format::isCoords怎么用?PHP Format::isCoords使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtism\common\utils\Format
的用法示例。
在下文中一共展示了Format::isCoords方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testInvalidCoordinatesFormat
/**
* @dataProvider invalidCoordinatesFormatProvider
*/
public function testInvalidCoordinatesFormat($string)
{
$this->assertFalse(Format::isCoords($string));
}
示例2: stringToCoords
/**
* Transforms a string to a Coord object according to a given shape.
*
* @param string $string Coordinates as a string.
* @param int $shape A value from the Shape enumeration.
* @throws \InvalidArgumentException If $string is are not valid coordinates or $shape is not a value from the Shape enumeration.
* @throws \UnexpectedValueException If $string cannot be converted to a Coords object.
* @return \qtism\common\datatypes\Coords A Coords object.
*/
public static function stringToCoords($string, $shape)
{
if (Format::isCoords($string)) {
$stringCoords = explode(",", $string);
$intCoords = array();
foreach ($stringCoords as $sC) {
$intCoords[] = intval($sC);
}
// Maybe it was accepted has coords, but is it buildable with
// the given shape?
return new Coords($shape, $intCoords);
} else {
throw new UnexpectedValueException("'{$string}' cannot be converted to Coords.");
}
}