public function process()
    {
        $rule = $this->getRule();
        $state = $this->getState();
        $variableIdentifier = $rule->getIdentifier();
        
        $var = $state->getVariable($variableIdentifier);
        
        if (is_null($var) === true) {
            $msg = "No variable with identifier '${variableIdentifier}' to be set in the current state.";
            throw new RuleProcessingException($msg, $this, RuleProcessingException::NONEXISTENT_VARIABLE);
        } elseif (!$var instanceof ResponseVariable) {
            $msg = "The variable to set '${variableIdentifier}' is not an instance of 'ResponseVariable'.";
            throw new RuleProcessingException($msg, $this, RuleProcessingException::WRONG_VARIABLE_TYPE);
        }
        
        try {
            $expressionEngine = new ExpressionEngine($rule->getExpression(), $state);
            $val = $expressionEngine->process();
            $var->setCorrectResponse($val);
        } catch (InvalidArgumentException $e) {
            $varBaseType = (BaseType::getNameByConstant($var->getBaseType())  === false) ? 'noBaseType' : BaseType::getNameByConstant($var->getBaseType());
            $varCardinality = (Cardinality::getNameByConstant($var->getCardinality()));
            // The affected value does not match the baseType of the variable $var.
            $msg = "Unable to set value ${val} to variable '${variableIdentifier}' (cardinality = ${varCardinality}, baseType = ${varBaseType}).";
            throw new RuleProcessingException($msg, $this, RuleProcessingException::WRONG_VARIABLE_BASETYPE, $e);
        } catch (ExpressionProcessingException $e) {
            $msg = "An error occured while processing the expression bound with the 'SetCorrectResponse' rule.";
            throw new RuleProcessingException($msg, $this, RuleProcessingException::RUNTIME_ERROR, $e);
        }
    }