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

        if (($c = count($operands)) < 2) {
            $msg = "The 'qtism.runtime.expressions.operators.custom.Implode' custom operator takes 2 sub-expressions as parameters, ${c} given.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::NOT_ENOUGH_OPERANDS);
        } elseif ($operands->containsNull() === true) {
            return null;
        } elseif ($operands->exclusivelyString() === false) {
            $msg = "The 'qtism.runtime.expressions.operators.custom.Implode' custom operator only accepts operands with a string baseType.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_BASETYPE);
        } elseif ($operands[0]->getCardinality() !== Cardinality::SINGLE) {
            $msg = "The 'qtism.runtime.expressions.operators.custom.Implode' custom operator only accepts a first operand with single cardinality.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_CARDINALITY);
        } elseif ($operands[1]->getCardinality() !== Cardinality::MULTIPLE && $operands[1]->getCardinality() !== Cardinality::ORDERED) {
            $msg = "The 'qtism.runtime.expressions.operators.custom.Implode' custom operator only accepts a second operand with multiple or ordered cardinality.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_CARDINALITY);
        }

        $glue = $operands[0]->getValue();
        $pieces = $operands[1];

        // Note: implode() is binary-safe \0/!
        $string = implode($glue, $pieces->getArrayCopy());

        return new QtiString($string);
    }
public function process()
    {
        $operands = $this->getOperands();

        if (($c = count($operands)) < 2) {
            $msg = "The 'qtism.runtime.expressions.operators.custom.Implode' custom operator takes 2 sub-expressions as parameters, ${c} given.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::NOT_ENOUGH_OPERANDS);
        } elseif ($operands->containsNull() === true) {
            return null;
        } elseif ($operands->exclusivelyString() === false) {
            $msg = "The 'qtism.runtime.expressions.operators.custom.Implode' custom operator only accepts operands with a string baseType.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_BASETYPE);
        } elseif ($operands[0]->getCardinality() !== Cardinality::SINGLE) {
            $msg = "The 'qtism.runtime.expressions.operators.custom.Implode' custom operator only accepts a first operand with single cardinality.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_CARDINALITY);
        } elseif ($operands[1]->getCardinality() !== Cardinality::MULTIPLE && $operands[1]->getCardinality() !== Cardinality::ORDERED) {
            $msg = "The 'qtism.runtime.expressions.operators.custom.Implode' custom operator only accepts a second operand with multiple or ordered cardinality.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_CARDINALITY);
        }

        $glue = $operands[0]->getValue();
        $pieces = $operands[1];

        // Note: implode() is binary-safe \0/!
        $string = implode($glue, $pieces->getArrayCopy());

        return new QtiString($string);
    }
public function process ( ) { $ operands = $ this -> getOperands ( ) ; if ( ( $ c = count ( $ operands ) ) < 2 ) { $ msg = "The 'qtism.runtime.expressions.operators.custom.Implode' custom operator takes 2 sub-expressions as parameters, ${c} given." ; throw new OperatorProcessingException ( $ msg , $ this , OperatorProcessingException :: NOT_ENOUGH_OPERANDS ) ; } elseif ( $ operands -> containsNull ( ) === true ) { return null ; } elseif ( $ operands -> exclusivelyString ( ) === false ) { $ msg = "The 'qtism.runtime.expressions.operators.custom.Implode' custom operator only accepts operands with a string baseType." ; throw new OperatorProcessingException ( $ msg , $ this , OperatorProcessingException :: WRONG_BASETYPE ) ; } elseif ( $ operands [ 0 ] -> getCardinality ( ) !== Cardinality :: SINGLE ) { $ msg = "The 'qtism.runtime.expressions.operators.custom.Implode' custom operator only accepts a first operand with single cardinality." ; throw new OperatorProcessingException ( $ msg , $ this , OperatorProcessingException :: WRONG_CARDINALITY ) ; } elseif ( $ operands [ 1 ] -> getCardinality ( ) !== Cardinality :: MULTIPLE && $ operands [ 1 ] -> getCardinality ( ) !== Cardinality :: ORDERED ) { $ msg = "The 'qtism.runtime.expressions.operators.custom.Implode' custom operator only accepts a second operand with multiple or ordered cardinality." ; throw new OperatorProcessingException ( $ msg , $ this , OperatorProcessingException :: WRONG_CARDINALITY ) ; } $ glue = $ operands [ 0 ] -> getValue ( ) ; $ pieces = $ operands [ 1 ] ; // Note: implode() is binary-safe \0/! $ string = implode ( $ glue , $ pieces -> getArrayCopy ( ) ) ; return new QtiString ( $ string ) ; }
Process the expression by implementing PHP core's implode function.

@return String The split value of the second sub-expression given as a parameter.
@throws \qtism\runtime\expressions\operators\OperatorProcessingException If something goes wrong.
Process the expression by implementing PHP core s implode function .