@param string         $fieldName
@param string         $comparing
@param string         $operator
@param string|integer $expecting

@return bool
978785
protected function middleware($fieldName, $comparing, $operator, $expecting)
    {
        if (in_array($operator, array("<", ">", "==", "<=", ">="), true)) {
            $func = function($a, $b) use ($operator) {
                switch ($operator){
                    case "<":
                        return ($a < $b);
                    case ">":
                        return ($a > $b);
                    case "==":
                        return ($a == $b);
                    case ">=":
                        return ($a >= $b);
                    case "<=":
                        return ($a <= $b);
                }
            };

            return ($func($comparing, $expecting) === true) ?: $this->error($fieldName, $operator);
        }

        return false;
    }
680668
protected function applySqliteEquality($comparison, $query, $field, $input) {
		switch($comparison)
		{
			case '=':
				$sql = sprintf('%s IS %s', $field, $input);
				return $query->whereRaw($sql);
			case '!=':
				$sql = sprintf('%s IS NOT %s', $field, $input);
				return $query->whereRaw($sql);
		}
	}
1311706
protected function isEquals($value, $compareField, $field)
    {
        is_array($compareField) && $compareField = $compareField[0];
        return isset($this->data[$field]) && isset($this->data[$compareField]) && $this->data[$field] == $this->data[$compareField];
    }
1201244
public function equals($compare)
    {
        if ($compare instanceof self) {
            return ($compare->className == $this->className && $compare->propertyName == $this->propertyName);
        }
        
        return false;
    }
294260
protected function match($operator, $pattern, $value)
    {
        $value   = strtolower($value);
        $pattern = strtolower($pattern);
        switch ($operator) {
            case '=':
                return $value === $pattern;
            case '!=':
                return $value !== $pattern;
            case '^=':
                return preg_match('/^'.preg_quote($pattern, '/').'/', $value);
            case '$=':
                return preg_match('/'.preg_quote($pattern, '/').'$/', $value);
            case '*=':
                if ($pattern[0] == '/') {
                    return preg_match($pattern, $value);
                }

                return preg_match("/".$pattern."/i", $value);
        }

        return false;
    }
825159
public function equals($compare)
    {
        if (($compare instanceof self) == false) {
            return false;
        }
        
        $class        = $this->getDeclaringClass();
        $compareClass = $compare->getDeclaringClass();
        if ((null == $class && null != $compareClass) || null != $class && null == $compareClass) {
            return false;
        }
        
        if (null == $class) {
            return ($compare->routineName == $this->routineName && $compare->paramName == $this->paramName);
        }
        
        return ($compareClass->getName() == $class->getName() && $compare->routineName == $this->routineName && $compare->paramName == $this->paramName);
    }
1121675
protected function equality($comparison, $operand)
    {
        return $this->expr->addCondition(new Operator\Equality(
            $this,
            $comparison,
            $this->expr->value($operand)
        ));
    }
826543
private function match($operator, $size)
    {
        $error = false;

        switch ($operator) {
            case '==':
                if ($size == $this->value) {
                    $error = true;
                }
            break;

            case '>':
                if ($size > $this->value) {
                    $error = true;
				}
            break;

            case '<':
                if ($size < $this->value) {
                    $error = true;
                }
            break;

            case '!=':
                if ($size != $this->value) {
                    $error = true;
                }
            break;

            case '<=':
                if ($size <= $this->value) {
                    $error = true;
                }
            break;

            case '>=':
                if ($size >= $this->value) {
                    $error = true;
                }
            break;
		}

        return $error;
	}
447564
private function compareDate(DateTime $value1, DateTime $value2, $operator)
    {
        $diff = $value1->format('U') - $value2->format('U');
        switch ($operator) {
            case FieldExpression::EQUALS:
                return $diff === 0;
            case FieldExpression::NOT_EQUALS:
                return $diff !== 0;

            case FieldExpression::GT:
                return $diff > 0;

            case FieldExpression::LT:
                return $diff < 0;
        }

        $errMsg = 'unknown field operator';
        throw new InvalidArgumentException($errMsg);
    }
1256402
private function _having($operator, array $fields)
    {
        $count = count($fields);

        if ($count < 1 || $count > 3)
        {
            $fields = var_export($fields, true);
            throw new \InvalidArgumentException($fields);
        }

        $this->storageHaving[] = [$operator => $fields];

        return $this;
    }
972084
protected static function assertEqual($calculatedValue, $expectedValue, bool $identical = true, bool $exitOnError = false): bool
    {
        $result = $identical 
                ? $calculatedValue === $expectedValue 
                : $calculatedValue ==  $expectedValue;
        $msg = '';
        if (!$result) {
            $value = preg_replace('/  +/', ' ', str_replace("\n", '', print_r($calculatedValue, true)));
            $msg = '     Found: ' . self::varExport($calculatedValue) . ",\n      Expected: " . self::varExport($expectedValue);
        }
        return self::assert($result, $msg, $exitOnError);
    }
1314111
public function findOne($arg = null, $operator = '=', $fields = array('*'))
    {
        return $this->find($arg, $operator, $fields)->limit(0, 1);
    }
344954
public function matchSpecific(Constraint $provider, $compareBranches = false)
    {
        $noEqualOp = str_replace('=', '', self::$transOpInt[$this->operator]);
        $providerNoEqualOp = str_replace('=', '', self::$transOpInt[$provider->operator]);

        $isEqualOp = self::OP_EQ === $this->operator;
        $isNonEqualOp = self::OP_NE === $this->operator;
        $isProviderEqualOp = self::OP_EQ === $provider->operator;
        $isProviderNonEqualOp = self::OP_NE === $provider->operator;

        // '!=' operator is match when other operator is not '==' operator or version is not match
        // these kinds of comparisons always have a solution
        if ($isNonEqualOp || $isProviderNonEqualOp) {
            return !$isEqualOp && !$isProviderEqualOp
                || $this->versionCompare($provider->version, $this->version, '!=', $compareBranches);
        }

        // an example for the condition is <= 2.0 & < 1.0
        // these kinds of comparisons always have a solution
        if ($this->operator !== self::OP_EQ && $noEqualOp === $providerNoEqualOp) {
            return true;
        }

        if ($this->versionCompare($provider->version, $this->version, self::$transOpInt[$this->operator], $compareBranches)) {
            // special case, e.g. require >= 1.0 and provide < 1.0
            // 1.0 >= 1.0 but 1.0 is outside of the provided interval
            if ($provider->version === $this->version
                && self::$transOpInt[$provider->operator] === $providerNoEqualOp
                && self::$transOpInt[$this->operator] !== $noEqualOp) {
                return false;
            }

            return true;
        }

        return false;
    }
897200
public function where($field, $value, $comparison = '=', $logical = 'and')
    {
        $condition = $this->condition($field, $value, $comparison, $logical);

        if ($this->normalizeLogical($logical) === 'or') {
            $this->builder()->orWhere($condition);

            return $this;
        }

        $this->builder()->andWhere($condition);

        return $this;
    }
844267
public function compareString($expected, $actual)
    {
        $expected .= "\0";
        $actual .= "\0";
        $expectedLength = StringHelper::byteLength($expected);
        $actualLength = StringHelper::byteLength($actual);
        $diff = $expectedLength - $actualLength;
        for ($i = 0; $i < $actualLength; $i++) {
            $diff |= (ord($actual[$i]) ^ ord($expected[$i % $expectedLength]));
        }
        return $diff === 0;
    }
476384
public function when($field, $operator, $expected, \Closure $closure)
    {
        $field = $field instanceof Field ? $field : $this->field($field);

        $name = __METHOD__ . $field->name() . $operator . md5(json_encode($expected));

        $this->group($name, $closure);
        $this->getGroup($name)->condition($field, $operator, $expected);

        return $this;
    }
1174960
public function where($field, $operator = null, $value = null, $boolean = 'AND')
    {
        // If the developer is adding multiple where statements together,
        // we will enforce that by adding the approriate boolean.

        if ($this->condition && count($this->condition) > 0) {
            $this->condition[] = $boolean;
        }

        // Here we will make some assumptions about the operator. If only two values
        // are passed in, we will assume the operator is an equals sign. Furthermore,
        // we will identify if the value is null and apply the respective operator.

        list($value, $operator) = $this->prepareValueAndOperator(
            $value, $operator, func_num_args() == 2
        );

        $this->condition[] = [
            'field' => compact('field'),
            'op' => $operator,
            'value' => $value
        ];

        return $this;
    }