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

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

        if ($operands->sameBaseType() === false) {
            $msg = "The Member operator only accepts values with the same baseType.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_BASETYPE);
        }

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

        // The first expression must have single cardinality.
        if (CommonUtils::inferCardinality($operand1) !== Cardinality::SINGLE) {
            $msg = "The first operand of the Member operator must have a single cardinality.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_CARDINALITY);
        }

        // The second expression must have multiple or ordered cardinality.
        $cardinality = CommonUtils::inferCardinality($operand2);
        if ($cardinality === Cardinality::SINGLE) {
            $operand2 = new MultipleContainer($operand1->getBaseType(), array($operand2));
        } elseif ($cardinality !== Cardinality::MULTIPLE && $cardinality !== Cardinality::ORDERED) {
            $msg = "The second operand of the Member operator must have a single, multiple or ordered cardinality.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_CARDINALITY);
        }

        return new QtiBoolean($operand2->contains($operand1));
    }
public function process()
    {
        $operands = $this->getOperands();

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

        if ($operands->sameBaseType() === false) {
            $msg = "The Member operator only accepts values with the same baseType.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_BASETYPE);
        }

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

        // The first expression must have single cardinality.
        if (CommonUtils::inferCardinality($operand1) !== Cardinality::SINGLE) {
            $msg = "The first operand of the Member operator must have a single cardinality.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_CARDINALITY);
        }

        // The second expression must have multiple or ordered cardinality.
        $cardinality = CommonUtils::inferCardinality($operand2);
        if ($cardinality === Cardinality::SINGLE) {
            $operand2 = new MultipleContainer($operand1->getBaseType(), array($operand2));
        } elseif ($cardinality !== Cardinality::MULTIPLE && $cardinality !== Cardinality::ORDERED) {
            $msg = "The second operand of the Member operator must have a single, multiple or ordered cardinality.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_CARDINALITY);
        }

        return new QtiBoolean($operand2->contains($operand1));
    }
public function process ( ) { $ operands = $ this -> getOperands ( ) ; if ( $ operands -> containsNull ( ) === true ) { return null ; } if ( $ operands -> sameBaseType ( ) === false ) { $ msg = "The Member operator only accepts values with the same baseType." ; throw new OperatorProcessingException ( $ msg , $ this , OperatorProcessingException :: WRONG_BASETYPE ) ; } $ operand1 = $ operands [ 0 ] ; $ operand2 = $ operands [ 1 ] ; // The first expression must have single cardinality. if ( CommonUtils :: inferCardinality ( $ operand1 ) !== Cardinality :: SINGLE ) { $ msg = "The first operand of the Member operator must have a single cardinality." ; throw new OperatorProcessingException ( $ msg , $ this , OperatorProcessingException :: WRONG_CARDINALITY ) ; } // The second expression must have multiple or ordered cardinality. $ cardinality = CommonUtils :: inferCardinality ( $ operand2 ) ; if ( $ cardinality === Cardinality :: SINGLE ) { $ operand2 = new MultipleContainer ( $ operand1 -> getBaseType ( ) , array ( $ operand2 ) ) ; } elseif ( $ cardinality !== Cardinality :: MULTIPLE && $ cardinality !== Cardinality :: ORDERED ) { $ msg = "The second operand of the Member operator must have a single, multiple or ordered cardinality." ; throw new OperatorProcessingException ( $ msg , $ this , OperatorProcessingException :: WRONG_CARDINALITY ) ; } return new QtiBoolean ( $ operand2 -> contains ( $ operand1 ) ) ; }
Process the Member operator.

@return boolean Whether the first operand is contained by the second one as a boolean value, or NULL if any of the sub-expressions are NULL.
@throws \qtism\runtime\expressions\operators\OperatorProcessingException
Process the Member operator .