public function process()
    {
        $operands = $this->getOperands();

        if ($operands->containsNull() === true) {
            return null;
        }

        if ($operands->exclusivelySingle() === false) {
            $msg = "The Subtract operator only accepts operands with a single cardinality";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_CARDINALITY);
        }

        if ($operands->exclusivelyNumeric() === false) {
            $msg = "The Subtract operator only accepts operands with a baseType of integer or float";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_BASETYPE);
        }

        $operand1 = $operands[0];
        $operand2 = $operands[1];

        $subtract = $operand1->getValue() - $operand2->getValue();

        return (is_int($subtract) === true) ? new QtiInteger($subtract) : new QtiFloat($subtract);
    }
public function process()
    {
        $operands = $this->getOperands();

        if ($operands->containsNull() === true) {
            return null;
        }

        if ($operands->exclusivelySingle() === false) {
            $msg = "The Subtract operator only accepts operands with a single cardinality";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_CARDINALITY);
        }

        if ($operands->exclusivelyNumeric() === false) {
            $msg = "The Subtract operator only accepts operands with a baseType of integer or float";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_BASETYPE);
        }

        $operand1 = $operands[0];
        $operand2 = $operands[1];

        $subtract = $operand1->getValue() - $operand2->getValue();

        return (is_int($subtract) === true) ? new QtiInteger($subtract) : new QtiFloat($subtract);
    }
public function process ( ) { $ operands = $ this -> getOperands ( ) ; if ( $ operands -> containsNull ( ) === true ) { return null ; } if ( $ operands -> exclusivelySingle ( ) === false ) { $ msg = "The Subtract operator only accepts operands with a single cardinality" ; throw new OperatorProcessingException ( $ msg , $ this , OperatorProcessingException :: WRONG_CARDINALITY ) ; } if ( $ operands -> exclusivelyNumeric ( ) === false ) { $ msg = "The Subtract operator only accepts operands with a baseType of integer or float" ; throw new OperatorProcessingException ( $ msg , $ this , OperatorProcessingException :: WRONG_BASETYPE ) ; } $ operand1 = $ operands [ 0 ] ; $ operand2 = $ operands [ 1 ] ; $ subtract = $ operand1 -> getValue ( ) - $ operand2 -> getValue ( ) ; return ( is_int ( $ subtract ) === true ) ? new QtiInteger ( $ subtract ) : new QtiFloat ( $ subtract ) ; }
Process the Subtract operator.

@return float|integer|null A single float or if both sub-expressions are integers, a single integer or NULL if either of the sub-expressions is NULL.
@throws \qtism\runtime\expressions\operators\OperatorProcessingException
Process the Subtract operator .