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 QtiCoords($shape, $intCoords);
        } else {
            throw new UnexpectedValueException("'${string}' cannot be converted to Coords.");
        }
    }
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 QtiCoords($shape, $intCoords);
        } else {
            throw new UnexpectedValueException("'${string}' cannot be converted to Coords.");
        }
    }
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 QtiCoords ( $ shape , $ intCoords ) ; } else { throw new UnexpectedValueException ( "'${string}' cannot be converted to Coords." ) ; } }
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.
Transforms a string to a Coord object according to a given shape .