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

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

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

        if ($operands->exclusivelyString() === false) {
            $msg = "The PatternMatch operator only accepts operands with a string baseType.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_BASETYPE);
        }

        $rawPattern = $this->getExpression()->getPattern();
        $pattern = OperatorUtils::prepareXsdPatternForPcre($rawPattern);
        $result = @preg_match($pattern, $operands[0]->getValue());

        if ($result === 1) {
            return new QtiBoolean(true);
        } elseif ($result === 0) {
            return new QtiBoolean(false);
        } else {
            $errorType = OperatorUtils::lastPregErrorMessage();
            $msg = "An internal error occured while processing the regular expression '${rawPattern}': ${errorType}.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::RUNTIME_ERROR);
        }
    }
public function process()
    {
        $operands = $this->getOperands();

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

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

        if ($operands->exclusivelyString() === false) {
            $msg = "The PatternMatch operator only accepts operands with a string baseType.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_BASETYPE);
        }

        $rawPattern = $this->getExpression()->getPattern();
        $pattern = OperatorUtils::prepareXsdPatternForPcre($rawPattern);
        $result = @preg_match($pattern, $operands[0]->getValue());

        if ($result === 1) {
            return new QtiBoolean(true);
        } elseif ($result === 0) {
            return new QtiBoolean(false);
        } else {
            $errorType = OperatorUtils::lastPregErrorMessage();
            $msg = "An internal error occured while processing the regular expression '${rawPattern}': ${errorType}.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::RUNTIME_ERROR);
        }
    }
public function process ( ) { $ operands = $ this -> getOperands ( ) ; if ( $ operands -> containsNull ( ) === true ) { return null ; } if ( $ operands -> exclusivelySingle ( ) === false ) { $ msg = "The PatternMatch operator only accepts operands with a single cardinality." ; throw new OperatorProcessingException ( $ msg , $ this , OperatorProcessingException :: WRONG_CARDINALITY ) ; } if ( $ operands -> exclusivelyString ( ) === false ) { $ msg = "The PatternMatch operator only accepts operands with a string baseType." ; throw new OperatorProcessingException ( $ msg , $ this , OperatorProcessingException :: WRONG_BASETYPE ) ; } $ rawPattern = $ this -> getExpression ( ) -> getPattern ( ) ; $ pattern = OperatorUtils :: prepareXsdPatternForPcre ( $ rawPattern ) ; $ result = @ preg_match ( $ pattern , $ operands [ 0 ] -> getValue ( ) ) ; if ( $ result === 1 ) { return new QtiBoolean ( true ) ; } elseif ( $ result === 0 ) { return new QtiBoolean ( false ) ; } else { $ errorType = OperatorUtils :: lastPregErrorMessage ( ) ; $ msg = "An internal error occured while processing the regular expression '${rawPattern}': ${errorType}." ; throw new OperatorProcessingException ( $ msg , $ this , OperatorProcessingException :: RUNTIME_ERROR ) ; } }
Process the PatternMatch.

@return boolean|null A single boolean with a value of true if the sub-expression matches the pattern and false if it does not. If the sub-expression is NULL, the the operator results in NULL.
@throws \qtism\runtime\expressions\operators\OperatorProcessingException
Process the PatternMatch .