helpers/class.LegacyVariableFiller.php
protected static function transform($baseType, $value) {
        
        switch ($baseType) {
            case BaseType::BOOLEAN:
                if ($value === '') {
                    return null;
                }
                else {
                    return ($value === 'true') ? true : false;
                }
            break;
            
            case BaseType::DIRECTED_PAIR:
                if (is_array($value) === false) {
                    $msg = "Cannot transform a value into a QTI directedPair, it is not an array, '" . gettype($value) . "' given";
                    throw new OutOfRangeException($msg);
                }
                else if (empty($value[0])) {
                    $msg = "Cannot transform a value into a QTI directedPair, the first identifier was not given.";
                    throw new OutOfRangeException($msg);
                }
                else if (empty($value[1])) {
                    $msg = "Cannot transform a value into a QTI directedPair, the second identifier was not given.";
                    throw new OutOfRangeException($msg);
                }
                else {
                    return new QtiDirectedPair($value[0], $value[1]);
                }
            break;
            
            case BaseType::PAIR:
                if (is_array($value) === false) {
                    $msg = "Cannot transform a value into a QTI pair, it is not an array, '" . gettype($value) . "' given";    
                    throw new OutOfRangeException($msg);
                }
                else if (empty($value[0])) {
                    $msg = "Cannot transform a value into a QTI pair, the first identifier was not given.";
                    throw new OutOfRangeException($msg);
                }
                else if (empty($value[1])) {
                    $msg = "Cannot transform a value into a QTI pair, the second identifier was not given.";
                    throw new OutOfRangeException($msg);
                }
                else {
                    return new QtiPair($value[0], $value[1]);
                }
            break;
            
            case BaseType::STRING:
                return new QtiString($value);
            break;
            case BaseType::IDENTIFIER:
                return ($value !== '') ? new QtiIdentifier($value) : null;
            break;
            
            case BaseType::INTEGER:
                return ($value !== '') ? new QtiInteger(intval($value)) : null;
            break;
            
            case BaseType::FLOAT:
                return ($value !== '') ? new QtiFloat(floatval($value)) : null;
            break;
            
            case BaseType::POINT:
                if (is_array($value) === false) {
                    $msg = "Cannot transform a value into a QTI point, it is not an array, '" . gettype($value) . "' given";
                    throw new OutOfRangeException($msg);
                }
                else if (empty($value[0])) {
                    $msg = "Cannot transform a value into a QTI point, X was not given.";
                    throw new OutOfRangeException($msg);
                }
                else if (empty($value[1])) {
                    $msg = "Cannot transform a value into a QTI point, Y was not given.";
                    throw new OutOfRangeException($msg);
                }
                else {
                    return new QtiPoint(intval($value[0]), intval($value[1]));
                }
            break;
            
            default:
                $msg = "Not supported baseType constant '${baseType}'.";
                throw new InvalidArgumentException($msg);
            break;
        }
    }
protected static function transform($baseType, $value) {
        
        switch ($baseType) {
            case BaseType::BOOLEAN:
                if ($value === '') {
                    return null;
                }
                else {
                    return ($value === 'true') ? true : false;
                }
            break;
            
            case BaseType::DIRECTED_PAIR:
                if (is_array($value) === false) {
                    $msg = "Cannot transform a value into a QTI directedPair, it is not an array, '" . gettype($value) . "' given";
                    throw new OutOfRangeException($msg);
                }
                else if (empty($value[0])) {
                    $msg = "Cannot transform a value into a QTI directedPair, the first identifier was not given.";
                    throw new OutOfRangeException($msg);
                }
                else if (empty($value[1])) {
                    $msg = "Cannot transform a value into a QTI directedPair, the second identifier was not given.";
                    throw new OutOfRangeException($msg);
                }
                else {
                    return new QtiDirectedPair($value[0], $value[1]);
                }
            break;
            
            case BaseType::PAIR:
                if (is_array($value) === false) {
                    $msg = "Cannot transform a value into a QTI pair, it is not an array, '" . gettype($value) . "' given";    
                    throw new OutOfRangeException($msg);
                }
                else if (empty($value[0])) {
                    $msg = "Cannot transform a value into a QTI pair, the first identifier was not given.";
                    throw new OutOfRangeException($msg);
                }
                else if (empty($value[1])) {
                    $msg = "Cannot transform a value into a QTI pair, the second identifier was not given.";
                    throw new OutOfRangeException($msg);
                }
                else {
                    return new QtiPair($value[0], $value[1]);
                }
            break;
            
            case BaseType::STRING:
                return new QtiString($value);
            break;
            case BaseType::IDENTIFIER:
                return ($value !== '') ? new QtiIdentifier($value) : null;
            break;
            
            case BaseType::INTEGER:
                return ($value !== '') ? new QtiInteger(intval($value)) : null;
            break;
            
            case BaseType::FLOAT:
                return ($value !== '') ? new QtiFloat(floatval($value)) : null;
            break;
            
            case BaseType::POINT:
                if (is_array($value) === false) {
                    $msg = "Cannot transform a value into a QTI point, it is not an array, '" . gettype($value) . "' given";
                    throw new OutOfRangeException($msg);
                }
                else if (empty($value[0])) {
                    $msg = "Cannot transform a value into a QTI point, X was not given.";
                    throw new OutOfRangeException($msg);
                }
                else if (empty($value[1])) {
                    $msg = "Cannot transform a value into a QTI point, Y was not given.";
                    throw new OutOfRangeException($msg);
                }
                else {
                    return new QtiPoint(intval($value[0]), intval($value[1]));
                }
            break;
            
            default:
                $msg = "Not supported baseType constant '${baseType}'.";
                throw new InvalidArgumentException($msg);
            break;
        }
    }
Transform $value in a $baseType datatype.

@param integer $baseType
@param mixed $value
@return mixed
@throws InvalidArgumentException If $baseType is unknown.
@throws OutOfRangeException If $value cannot be transformed into $baseType datatype.