Skip to content

Commit 72457ed

Browse files
committed
ADD conditional function hasValue as alternative to notNull
1 parent c4e9f2a commit 72457ed

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ prefixes the `and` and `or` logical operators for clarity.
263263
| `NOT BETWEEN` | `notBetween($op, $min, $max)` | `andNotBetween($op, $min, $max)` | `orNotBetween($op, $min, $max)` |
264264
| `IN` | `in($op, $array)` | `andIn($op, $array)` | `orIn($op, $array)` |
265265
| `NOT IN` | `notIn($op, $array)` | `andNotIn($op, $array)` | `orNotIn($op, $array)` |
266+
| `IS NOT NULL` | `hasValue($op)` | `andHasValue($op)` | `orHasValue($op)` |
266267

267268
> **About `ConditionList` class**
268269
>

src/Expressions/Logical/ConditionList.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ public function null($value, $negated = false, $connector = LogicConnectors::AND
352352
{
353353
return $this->add(new ConditionItem($this->genNullExpression($value, $negated), $connector));
354354
}
355+
#endregion
355356

356357
#region NULL with connector and negation
357358
public function notNull($value)
@@ -376,6 +377,19 @@ public function orNotNull($value)
376377
}
377378
#endregion
378379

380+
#region HasValue (NOT NULL but better negation readability)
381+
public function hasValue($value, $negated = false, $connector = LogicConnectors::AND)
382+
{
383+
return $this->null($value, !$negated, $connector);
384+
}
385+
public function andHasValue($value)
386+
{
387+
return $this->hasValue($value);
388+
}
389+
public function orHasValue($value)
390+
{
391+
return $this->hasValue($value, false, LogicConnectors::OR);
392+
}
379393
#endregion
380394

381395
#region Equals OR NULL

0 commit comments

Comments
 (0)