Firestore/src/Query.php
public function where($fieldPath, $operator, $value)
    {
        if ($value instanceof FieldValueInterface) {
            throw new \InvalidArgumentException(sprintf(
                'Value cannot be a `%s` value.',
                FieldValue::class
            ));
        }

        if (!($fieldPath instanceof FieldPath)) {
            $fieldPath = FieldPath::fromString($fieldPath);
        }

        $escapedPathString = $fieldPath->pathString();

        $operator = array_key_exists($operator, $this->shortOperators)
            ? $this->shortOperators[$operator]
            : $operator;

        if (!in_array($operator, $this->allowedOperators)) {
            throw new \InvalidArgumentException(sprintf(
                'Operator %s is not a valid operator',
                $operator
            ));
        }

        if ((is_float($value) && is_nan($value)) || is_null($value)) {
            if ($operator !== self::OP_EQUAL) {
                throw new \InvalidArgumentException('Null and NaN are allowed only with operator EQUALS.');
            }

            $unaryOperator = is_nan($value)
                ? self::OP_NAN
                : self::OP_NULL;

            $filter = [
                'unaryFilter' => [
                    'field' => [
                        'fieldPath' => $escapedPathString
                    ],
                    'op' => $unaryOperator
                ]
            ];
        } else {
            $filter = [
                'fieldFilter' => [
                    'field' => [
                        'fieldPath' => $escapedPathString,
                    ],
                    'op' => $operator,
                    'value' => $this->valueMapper->encodeValue($value)
                ]
            ];
        }

        $query = [
            'where' => [
                'compositeFilter' => [
                    'op' => Operator::PBAND,
                    'filters' => [
                        $filter
                    ]
                ]
            ]
        ];

        return $this->newQuery($query);
    }
public function where($fieldPath, $operator, $value)
    {
        if ($value instanceof FieldValueInterface) {
            throw new \InvalidArgumentException(sprintf(
                'Value cannot be a `%s` value.',
                FieldValue::class
            ));
        }

        if (!($fieldPath instanceof FieldPath)) {
            $fieldPath = FieldPath::fromString($fieldPath);
        }

        $escapedPathString = $fieldPath->pathString();

        $operator = array_key_exists($operator, $this->shortOperators)
            ? $this->shortOperators[$operator]
            : $operator;

        if (!in_array($operator, $this->allowedOperators)) {
            throw new \InvalidArgumentException(sprintf(
                'Operator %s is not a valid operator',
                $operator
            ));
        }

        if ((is_float($value) && is_nan($value)) || is_null($value)) {
            if ($operator !== self::OP_EQUAL) {
                throw new \InvalidArgumentException('Null and NaN are allowed only with operator EQUALS.');
            }

            $unaryOperator = is_nan($value)
                ? self::OP_NAN
                : self::OP_NULL;

            $filter = [
                'unaryFilter' => [
                    'field' => [
                        'fieldPath' => $escapedPathString
                    ],
                    'op' => $unaryOperator
                ]
            ];
        } else {
            $filter = [
                'fieldFilter' => [
                    'field' => [
                        'fieldPath' => $escapedPathString,
                    ],
                    'op' => $operator,
                    'value' => $this->valueMapper->encodeValue($value)
                ]
            ];
        }

        $query = [
            'where' => [
                'compositeFilter' => [
                    'op' => Operator::PBAND,
                    'filters' => [
                        $filter
                    ]
                ]
            ]
        ];

        return $this->newQuery($query);
    }
public function where ( $ fieldPath , $ operator , $ value ) { if ( $ value instanceof FieldValueInterface ) { throw new \ InvalidArgumentException ( sprintf ( 'Value cannot be a `%s` value.' , FieldValue :: class ) ) ; } if ( ! ( $ fieldPath instanceof FieldPath ) ) { $ fieldPath = FieldPath :: fromString ( $ fieldPath ) ; } $ escapedPathString = $ fieldPath -> pathString ( ) ; $ operator = array_key_exists ( $ operator , $ this -> shortOperators ) ? $ this -> shortOperators [ $ operator ] : $ operator ; if ( ! in_array ( $ operator , $ this -> allowedOperators ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Operator %s is not a valid operator' , $ operator ) ) ; } if ( ( is_float ( $ value ) && is_nan ( $ value ) ) || is_null ( $ value ) ) { if ( $ operator !== self :: OP_EQUAL ) { throw new \ InvalidArgumentException ( 'Null and NaN are allowed only with operator EQUALS.' ) ; } $ unaryOperator = is_nan ( $ value ) ? self :: OP_NAN : self :: OP_NULL ; $ filter = [ 'unaryFilter' => [ 'field' => [ 'fieldPath' => $ escapedPathString ] , 'op' => $ unaryOperator ] ] ; } else { $ filter = [ 'fieldFilter' => [ 'field' => [ 'fieldPath' => $ escapedPathString , ] , 'op' => $ operator , 'value' => $ this -> valueMapper -> encodeValue ( $ value ) ] ] ; } $ query = [ 'where' => [ 'compositeFilter' => [ 'op' => Operator :: PBAND , 'filters' => [ $ filter ] ] ] ] ; return $ this -> newQuery ( $ query ) ; }
Add a WHERE clause to the Query.

Example:
```
$query = $query->where('firstName', '=', 'John');
```

```
// Filtering against `null` and `NAN` is supported only with the equality operator.
$query = $query->where('coolnessPercentage', '=', NAN);
```

```
// Use `array-contains` to select documents where the array contains given elements.
$query = $query->where('friends', 'array-contains', ['Steve', 'Sarah']);
```

@param string|FieldPath $fieldPath The field to filter by.
@param string $operator The operator to filter by.
@param mixed $value The value to compare to.
@return Query A new instance of Query with the given changes applied.
@throws \InvalidArgumentException If an invalid operator or value is encountered.
Add a WHERE clause to the Query .