public function process()
    {
        $printedVariable = $this->getComponent();
        $identifier = $printedVariable->getIdentifier();
        $state = $this->getContext();

        if ($state[$identifier] === null) {
            return '';
        }

        $variable = $state->getVariable($identifier);
        $value = $variable->getValue();

        if ($value === null || $value === '' || ($value instanceof Container && $value->isNull() === true)) {
            return '';
        }

        if ($variable->getCardinality() === Cardinality::SINGLE) {
            return $this->processValue($variable->getBaseType(), $value);
        } elseif ($variable->getCardinality() === Cardinality::ORDERED) {
            $index = $printedVariable->getIndex();

            // $index might be a variable reference.
            if (is_string($index) === true && $state[$index] !== null) {
                $refIndex = $state[$index];

                if ($refIndex instanceof QtiInteger) {
                    // $index references an integer, that's correct.
                    $index = $refIndex->getValue();
                } else {
                    // $index references something else than an integer.
                    // This is not correct. We consider then we have
                    // no index given.
                    $index = -1;
                }
            }

            if (is_int($index) && $index >= 0 && isset($value[$index])) {
                return $this->processValue($variable->getBaseType(), $value[$index]);
            } else {
                // Display all values.
                return $this->processOrderedMultiple($variable);
            }
        } elseif ($variable->getCardinality() === Cardinality::MULTIPLE) {
            // Display all values.
            return $this->processOrderedMultiple($variable);
        } else {
            // This is a record.
            $field = $printedVariable->getField();

            if (empty($field) === false && isset($value[$field])) {
                $v = $value[$field];

                return $this->processValue(Utils::inferBaseType($v), $v);
            } else {
                // Display all values.
                return $this->processRecord($variable);
            }
        }
    }
public function process()
    {
        $printedVariable = $this->getComponent();
        $identifier = $printedVariable->getIdentifier();
        $state = $this->getContext();

        if ($state[$identifier] === null) {
            return '';
        }

        $variable = $state->getVariable($identifier);
        $value = $variable->getValue();

        if ($value === null || $value === '' || ($value instanceof Container && $value->isNull() === true)) {
            return '';
        }

        if ($variable->getCardinality() === Cardinality::SINGLE) {
            return $this->processValue($variable->getBaseType(), $value);
        } elseif ($variable->getCardinality() === Cardinality::ORDERED) {
            $index = $printedVariable->getIndex();

            // $index might be a variable reference.
            if (is_string($index) === true && $state[$index] !== null) {
                $refIndex = $state[$index];

                if ($refIndex instanceof QtiInteger) {
                    // $index references an integer, that's correct.
                    $index = $refIndex->getValue();
                } else {
                    // $index references something else than an integer.
                    // This is not correct. We consider then we have
                    // no index given.
                    $index = -1;
                }
            }

            if (is_int($index) && $index >= 0 && isset($value[$index])) {
                return $this->processValue($variable->getBaseType(), $value[$index]);
            } else {
                // Display all values.
                return $this->processOrderedMultiple($variable);
            }
        } elseif ($variable->getCardinality() === Cardinality::MULTIPLE) {
            // Display all values.
            return $this->processOrderedMultiple($variable);
        } else {
            // This is a record.
            $field = $printedVariable->getField();

            if (empty($field) === false && isset($value[$field])) {
                $v = $value[$field];

                return $this->processValue(Utils::inferBaseType($v), $v);
            } else {
                // Display all values.
                return $this->processRecord($variable);
            }
        }
    }
public function process ( ) { $ printedVariable = $ this -> getComponent ( ) ; $ identifier = $ printedVariable -> getIdentifier ( ) ; $ state = $ this -> getContext ( ) ; if ( $ state [ $ identifier ] === null ) { return '' ; } $ variable = $ state -> getVariable ( $ identifier ) ; $ value = $ variable -> getValue ( ) ; if ( $ value === null || $ value === '' || ( $ value instanceof Container && $ value -> isNull ( ) === true ) ) { return '' ; } if ( $ variable -> getCardinality ( ) === Cardinality :: SINGLE ) { return $ this -> processValue ( $ variable -> getBaseType ( ) , $ value ) ; } elseif ( $ variable -> getCardinality ( ) === Cardinality :: ORDERED ) { $ index = $ printedVariable -> getIndex ( ) ; // $index might be a variable reference. if ( is_string ( $ index ) === true && $ state [ $ index ] !== null ) { $ refIndex = $ state [ $ index ] ; if ( $ refIndex instanceof QtiInteger ) { // $index references an integer, that's correct. $ index = $ refIndex -> getValue ( ) ; } else { // $index references something else than an integer. // This is not correct. We consider then we have // no index given. $ index = - 1 ; } } if ( is_int ( $ index ) && $ index >= 0 && isset ( $ value [ $ index ] ) ) { return $ this -> processValue ( $ variable -> getBaseType ( ) , $ value [ $ index ] ) ; } else { // Display all values. return $ this -> processOrderedMultiple ( $ variable ) ; } } elseif ( $ variable -> getCardinality ( ) === Cardinality :: MULTIPLE ) { // Display all values. return $ this -> processOrderedMultiple ( $ variable ) ; } else { // This is a record. $ field = $ printedVariable -> getField ( ) ; if ( empty ( $ field ) === false && isset ( $ value [ $ field ] ) ) { $ v = $ value [ $ field ] ; return $ this -> processValue ( Utils :: inferBaseType ( $ v ) , $ v ) ; } else { // Display all values. return $ this -> processRecord ( $ variable ) ; } } }
Processes the encapsulated PrintedVariable object into a formatted
string, depending on the PrintedVariable object and the current context.

* If the value to format is an OrderedContainer, and no 'index' attribue value is given, the whole container is displayed.
* If no specific precision is given for a float display, the precision will be by default 6.

@return \qtism\data\content\TextRun A processed PrintedVariable as a TextRun object or the NULL value if the variable's value is NULL.
@throws \qtism\runtime\processing\PrintedVariableProcessingException If an error occurs while processing the PrintedVariable object into a TextRun object.
Processes the encapsulated PrintedVariable object into a formatted string depending on the PrintedVariable object and the current context .