/**
  * @dataProvider invalidCoordinatesFormatProvider
  */
 public function testInvalidCoordinatesFormat($string)
 {
     $this->assertFalse(Format::isCoords($string));
 }
예제 #2
0
파일: Utils.php 프로젝트: hutnikau/qti-sdk
 /**
  * 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.");
     }
 }