is(string $field, mixed $value)

Checks if $field is equal to $value, which can be string, numeric, array, object or
an operator (for that use the operator functions). The query object is returned.
771269
public function is($field, $value) {
		// Translate 'id' to '_id'
		if ( 'id' == $field && !is_array( $value ) ):
			$field = '_id';
			$value = ( $value instanceof \MongoId ) ? $value : new \MongoId($value);
		endif;
		
		// Create Mongo reference if value is a model
		if ( $value instanceof \Mongoium\Document )
			$value = \MongoDBRef::create($value->getCollection(), $value->id);
		
		// Add field to the query
		$this->query['fields'][] = array($field => $value);
		return $this;
	}
775089
public static function isStringable($value)
	{
		return is_string($value)
				|| is_null($value)
				|| (is_object($value) && method_exists($value, '__toString'))
				|| is_scalar($value);
	}
478841
public function fieldValueEquals($field, $value, TraversableElement $container = null)
    {
        $node = $this->fieldExists($field, $container);
        $actual = $node->getValue();
        $regex = '/^'.preg_quote($value, '/').'$/ui';

        $message = sprintf('The field "%s" value is "%s", but "%s" expected.', $field, $actual, $value);

        $this->assert((bool) preg_match($regex, $actual), $message);
    }
103882
private function buildEquals($field, $value)
    {
        return $this::$open.$field.Operator::$equals.$value.$this::$close;
    }
1268427
function where($field, $operator, $value)
    {
        switch ($operator) {
            //EQUALITY
            case '=':
                $this->requestDecorator->addParameter($field, '=', $value);
                break;
            //INEQUALITY
            case '!=':
            case '[ne]':
            case 'ne':
                $this->requestDecorator->addParameter($field, '[ne]', $value);
                break;
            //INCLUSION
            case '[in]':
            case 'in':
                $this->requestDecorator->addParameter($field, '[in]', $value);
                break;
            //EXCLUSION
            case '[nin]':
            case 'nin':
                $this->requestDecorator->addParameter($field, '[nin]', $value);
                break;
            //LESS THAN
            case '<':
            case '[lt]':
            case 'lt':
                $this->requestDecorator->addParameter($field, '[lt]', $value);
                break;
            //GREATER THAN
            case '>':
            case '[gt]':
            case 'gt':
                $this->requestDecorator->addParameter($field, '[gt]', $value);
                break;
            //LESS THAN OR EQUAL TO
            case '<=':
            case '[lte]':
            case 'lte':
                $this->requestDecorator->addParameter($field, '[lte]', $value);
                break;
            //GREATER THAN OR EQUAL TO
            case '>=':
            case '[gte]':
            case 'gte':
                $this->requestDecorator->addParameter($field, '[gte]', $value);
                break;
            //MATCH
            case 'match':
            case '[match]':
                $this->requestDecorator->addParameter($field, '[match]', $value);
                break;
            //LOCATION - NEAR
            case 'near':
            case '[near]':
                $this->requestDecorator->addParameter($field, '[near]', $value);
                break;
            //LOCATION - WITHIN
            case 'within':
            case '[within]':
                $this->requestDecorator->addParameter($field, '[within]', $value);
                break;
            default:
                $this->requestDecorator->addParameter($field, '[' . $operator . ']', $value);
        }
        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;
    }
635039
public static function findParamValue(&$value, &$operator): bool
    {
        if (is_array($value) || is_object($value)) {
            $value = static::assembleParamValue($value, $operator);
        } else {
            self::normalizeEmptyValue($value);

            $operator = self::parseParamOperator($value);

            if (is_numeric($value)) {
                $value = self::prependOperator($value, $operator);
            } else {
                $value = StringHelper::toLowerCase($value);

                if ($value !== ':empty:' || $value !== 'not :empty:') {
                    // Trim any whitespace from the value
                    $value = StringHelper::trim($value);

                    return false;
                }
            }
        }

        return true;
    }
1242334
public function where($field, $operator = null, $value = null, $boolean = 'and', $raw = false)
    {
        if (is_array($field)) {
            // If the column is an array, we will assume it is an array of
            // key-value pairs and can add them each as a where clause.
            return $this->addArrayOfWheres($field, $boolean, $raw);
        }

        // We'll bypass the 'has' and 'notHas' operator since they
        // only require two arguments inside the where method.
        $bypass = [Operator::$has, Operator::$notHas];

        // Here we will make some assumptions about the operator. If only
        // 2 values are passed to the method, we will assume that
        // the operator is 'equals' and keep going.
        if (func_num_args() === 2 && in_array($operator, $bypass) === false) {
            list($value, $operator) = [$operator, '='];
        }

        if (! in_array($operator, Operator::all())) {
            throw new InvalidArgumentException("Invalid where operator: {$operator}");
        }

        // We'll escape the value if raw isn't requested.
        $value = $raw ? $value : $this->escape($value);

        $field = $this->escape($field, $ignore = null, 3);

        $this->addFilter($boolean, compact('field', 'operator', 'value'));

        return $this;
    }
648069
private function hasQueryOperators($value) : bool
    {
        if (! is_array($value) && ! is_object($value)) {
            return false;
        }

        if (is_object($value)) {
            $value = get_object_vars($value);
        }

        foreach ($value as $key => $_) {
            if (isset($key[0]) && $key[0] === '$') {
                return true;
            }
        }

        return false;
    }
737374
function typeOf (value) {
  var type = {
    hasValue: false,
    isArray: false,
    isPOJO: false,
    isNumber: false,
  };

  if (value !== undefined && value !== null) {
    type.hasValue = true;
    var typeName = typeof value;

    if (typeName === 'number') {
      type.isNumber = !isNaN(value);
    }
    else if (Array.isArray(value)) {
      type.isArray = true;
    }
    else {
      type.isPOJO =
        (typeName === 'object') &&
        !(value instanceof RegExp) &&
        !(value instanceof Date);
    }
  }

  return type;
}
671703
public function getValue($value = '', $field = 'id', $fieldOutput = '')
    {
        if (is_array($value) && count($value) > 0) {
            foreach ($value as $f => $v) {
                if (is_array($v)) {
                    $this->db->where($f, $v, self::OPERATOR_IS_IN);
                } else {
                    $this->db->where($f, $v, self::OPERATOR_EQUAL_TO);
                }
            }
        } else {
            $this->db->where($field, $value, self::OPERATOR_EQUAL_TO);
        }
        $result = $this->db->getOne($this->table, $fieldOutput);
        $this->debug->debug(__FUNCTION__, 'GET Result => ' . json_encode($result));
        if (isset($result->$fieldOutput)) {
            return $result->$fieldOutput;
        } else {
            return NULL;
        }
    }
961087
public function match($value, string $field, bool $strict = false): bool
    {
        if ($strict) {
            return $value === $this->getValidator()->getValue($field, null);
        }

        return $value == $this->getValidator()->getValue($field, null);
    }
1001652
public function isNull($field)
    {
        return new Expr\ComparisonExpression($field, new Expr\ValueIdentifier(null), Expr\ComparisonExpression::EQ);
    }
163812
public function value($field)
    {
        if (is_array($field)) {
            $values = array();
            foreach ($field as $key => $value) {
                $values[$key] = $this->value($value);
            }

            return $values;
        }

        return ($this->submitted && isset($this->values[$field])) ? $this->values[$field] : null;
    }
574012
public static function isEmail($value): bool
    {
        if (!static::isStringCastable($value)) {
            return false;
        }

        return filter_var((string) $value, FILTER_VALIDATE_EMAIL) !== false;
    }
757123
private function _is_mysql_function($value) {

        // returns TRUE if
        return (

            // is not an array
            !is_array($value) &&

            // has opening and closing parenthesis
            strpos($value, '(') !== false && strpos($value, ')') !== false &&

            // there is no white spaces from the beginning until the opening parenthesis
            preg_match('/^([^\s]+)\(/i', $value, $matches) &&

            // and match is not a MySQL function
            in_array(strtoupper($matches[1]), $this->mysql_functions)

        );

    }
88742
public function isAssignableFromValue($value)
    {
        switch ($this->name)
        {
            case self::INTEGER_NAME:
                return is_int($value);
            case self::FLOAT_NAME:
                return is_float($value);
            case self::STRING_NAME:
                return is_string($value);
            case self::BOOLEAN_NAME:
                return is_bool($value);
            case self::MIXED_NAME:
                return true;
            case self::RESOURCE_NAME:
                return is_resource($value);
            case self::OBJECT_NAME:
                return is_object($value);
            case self::NULL_NAME:
                return is_null($value);
            case self::CALLABLE_NAME:
                return is_callable($value);
            default:
                throw new Exception("Implementation error");
        }
    }