public function buildRegexCondition($operator, $operands)
    {
        if (!isset($operands[0], $operands[1])) {
            throw new InvalidParamException("Operator '$operator' requires two operands.");
        }
        list($column, $value) = $operands;
        if (!($value instanceof Regex)) {
            if (preg_match('~\/(.+)\/(.*)~', $value, $matches)) {
                $value = new Regex($matches[1], $matches[2]);
            } else {
                $value = new Regex($value, '');
            }
        }

        return [$column => $value];
    }
public function buildRegexCondition($operator, $operands)
    {
        if (!isset($operands[0], $operands[1])) {
            throw new InvalidParamException("Operator '$operator' requires two operands.");
        }
        list($column, $value) = $operands;
        if (!($value instanceof Regex)) {
            if (preg_match('~\/(.+)\/(.*)~', $value, $matches)) {
                $value = new Regex($matches[1], $matches[2]);
            } else {
                $value = new Regex($value, '');
            }
        }

        return [$column => $value];
    }
public function buildRegexCondition ( $ operator , $ operands ) { if ( ! isset ( $ operands [ 0 ] , $ operands [ 1 ] ) ) { throw new InvalidParamException ( "Operator '$operator' requires two operands." ) ; } list ( $ column , $ value ) = $ operands ; if ( ! ( $ value instanceof Regex ) ) { if ( preg_match ( '~\/(.+)\/(.*)~' , $ value , $ matches ) ) { $ value = new Regex ( $ matches [ 1 ] , $ matches [ 2 ] ) ; } else { $ value = new Regex ( $ value , '' ) ; } } return [ $ column => $ value ] ; }
Creates a Mongo regular expression condition.
@param string $operator the operator to use
@param array $operands the first operand is the column name.
The second operand is a single value that column value should be compared with.
@return array the generated Mongo condition.
@throws InvalidParamException if wrong number of operands have been given.
Creates a Mongo regular expression condition .