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

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

        if ($operands->exclusivelyMultipleOrOrdered() === false) {
            $msg = "The Random operator only accepts values with multiple or ordered cardinality.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_CARDINALITY);
        }

        $operand = $operands[0];
        $maxIndex = count($operand) - 1;

        return $operand[mt_rand(0, $maxIndex)];
    }
public function process()
    {
        $operands = $this->getOperands();

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

        if ($operands->exclusivelyMultipleOrOrdered() === false) {
            $msg = "The Random operator only accepts values with multiple or ordered cardinality.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_CARDINALITY);
        }

        $operand = $operands[0];
        $maxIndex = count($operand) - 1;

        return $operand[mt_rand(0, $maxIndex)];
    }
public function process ( ) { $ operands = $ this -> getOperands ( ) ; if ( $ operands -> containsNull ( ) === true ) { return null ; } if ( $ operands -> exclusivelyMultipleOrOrdered ( ) === false ) { $ msg = "The Random operator only accepts values with multiple or ordered cardinality." ; throw new OperatorProcessingException ( $ msg , $ this , OperatorProcessingException :: WRONG_CARDINALITY ) ; } $ operand = $ operands [ 0 ] ; $ maxIndex = count ( $ operand ) - 1 ; return $ operand [ mt_rand ( 0 , $ maxIndex ) ] ; }
Process the Random operator.

@return mixed|null A single cardinality QTI runtime compliant value or NULL if the operand is considered to be NULL.
@throws \qtism\runtime\expressions\operators\OperatorProcessingException
Process the Random operator .