src/Condition.php
/**
     * Adds a condition and tries to detect the type of the condition based on
     * the provided values. It is recommended to use an explicit method
     */
Adds a condition and tries to detect the type of the condition based on
the provided values. It is recommended to use an explicit method
Adds a condition and tries to detect the type of the condition based on the provided values . It is recommended to use an explicit method
public function add(string $column, string $operator, mixed $value, string $conjunction = 'AND'): self
    {
        if (!in_array($operator, self::ARITHMETIC_OPERATOR)) {
            throw new InvalidArgumentException('Invalid arithmetic operator (allowed: ' . implode(', ', self::ARITHMETIC_OPERATOR) . ')');
        }
        if (!in_array($conjunction, self::LOGIC_OPERATOR)) {
            throw new InvalidArgumentException('Invalid logic operator (allowed: ' . implode(', ', self::LOGIC_OPERATOR) . ')');
        }
        if ($operator === 'IN' && is_array($value)) {
            $expr = new Condition\In($column, $value, $conjunction);
        } elseif (($operator === '=' || $operator === 'IS') && $value === null) {
            $expr = new Condition\Nil($column, $conjunction);
        } elseif (($operator === '!=' || $operator === 'IS NOT') && $value === null) {
            $expr = new Condition\NotNil($column, $conjunction);
        } else {
            $expr = new Condition\Basic($column, $operator, $value, $conjunction);
        }
        return $this->addExpression($expr);
    }
public function add ( string $ column , string $ operator , mixed $ value , string $ conjunction = 'AND' ) : self { if ( ! in_array ( $ operator , self :: ARITHMETIC_OPERATOR ) ) { throw new InvalidArgumentException ( 'Invalid arithmetic operator (allowed: ' . implode ( ', ' , self :: ARITHMETIC_OPERATOR ) . ')' ) ; } if ( ! in_array ( $ conjunction , self :: LOGIC_OPERATOR ) ) { throw new InvalidArgumentException ( 'Invalid logic operator (allowed: ' . implode ( ', ' , self :: LOGIC_OPERATOR ) . ')' ) ; } if ( $ operator === 'IN' && is_array ( $ value ) ) { $ expr = new Condition \ In ( $ column , $ value , $ conjunction ) ; } elseif ( ( $ operator === '=' || $ operator === 'IS' ) && $ value === null ) { $ expr = new Condition \ Nil ( $ column , $ conjunction ) ; } elseif ( ( $ operator === '!=' || $ operator === 'IS NOT' ) && $ value === null ) { $ expr = new Condition \ NotNil ( $ column , $ conjunction ) ; } else { $ expr = new Condition \ Basic ( $ column , $ operator , $ value , $ conjunction ) ; } return $ this -> addExpression ( $ expr ) ; }
Adds a condition and tries to detect the type of the condition based on
 the provided values.
Adds a condition and tries to detect the type of the condition based on the provided values .