public function setOperator($operator)
    {
        if (!is_string($operator)) {
            throw new InvalidArgumentException(
                'Operator should be a string.'
            );
        }

        $operator = strtoupper($operator);
        if (!in_array($operator, $this->validOperators())) {
            throw new InvalidArgumentException(sprintf(
                'Comparison operator "%s" not allowed in this context.',
                $operator
            ));
        }

        $this->operator = $operator;
        return $this;
    }