public function addCondition($field, $value = '', $operator = '==')
    {
        if (!in_array($operator, self::$conditionOperators)) {
            throw new \InvalidArgumentException('Invalid operator');
        }

        // Transform a boolean value to its string representation.
        if (is_bool($value)) {
            $value = $value ? 'true' : 'false';
        }

        // Construct condition statement based on operator.
        if (in_array($operator, ['==', '!='])) {
            $this->conditions[] = $field . $operator . '"' . $value . '"';
        } elseif ($operator === 'guid') {
            $this->conditions[] = $field . '= Guid("'. $value . '")';
        } else {
            $this->conditions[] = $field . '.' . $operator . '("' . $value . '")';
        }

        return $this;
    }
public function addCondition($field, $value = '', $operator = '==')
    {
        if (!in_array($operator, self::$conditionOperators)) {
            throw new \InvalidArgumentException('Invalid operator');
        }

        // Transform a boolean value to its string representation.
        if (is_bool($value)) {
            $value = $value ? 'true' : 'false';
        }

        // Construct condition statement based on operator.
        if (in_array($operator, ['==', '!='])) {
            $this->conditions[] = $field . $operator . '"' . $value . '"';
        } elseif ($operator === 'guid') {
            $this->conditions[] = $field . '= Guid("'. $value . '")';
        } else {
            $this->conditions[] = $field . '.' . $operator . '("' . $value . '")';
        }

        return $this;
    }
public function addCondition ( $ field , $ value = '' , $ operator = '==' ) { if ( ! in_array ( $ operator , self :: $ conditionOperators ) ) { throw new \ InvalidArgumentException ( 'Invalid operator' ) ; } // Transform a boolean value to its string representation. if ( is_bool ( $ value ) ) { $ value = $ value ? 'true' : 'false' ; } // Construct condition statement based on operator. if ( in_array ( $ operator , [ '==' , '!=' ] ) ) { $ this -> conditions [ ] = $ field . $ operator . '"' . $ value . '"' ; } elseif ( $ operator === 'guid' ) { $ this -> conditions [ ] = $ field . '= Guid("' . $ value . '")' ; } else { $ this -> conditions [ ] = $ field . '.' . $ operator . '("' . $ value . '")' ; } return $ this ; }
Add a condition to the request.

@param string $field
The field to add the condition for.
@param string $value
The value to compare against.
@param string $operator
The operator to use in the condition:
- ==: Equal to the value.
- !=: Not equal to the value.
- StartsWith: Starts with the value.
- EndsWith: Ends with the value.
- Contains: Contains the value.
- guid: Equality for guid values. See Xero API.

@return $this
Add a condition to the request .