Skip to content

Commit f65b3a6

Browse files
add is null and is not null relations
1 parent 0f0490d commit f65b3a6

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Enum/Relation.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@ enum Relation
1919
case CONTAINS;
2020
case IN;
2121
case NOT_IN;
22+
case IS_NULL;
23+
case IS_NOT_NULL;
2224
}

src/IteratorFilter.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ private function evalString(Row $singleRow): bool
9595
Relation::STARTS_WITH => $result[$pos] && (str_starts_with(is_null($valueparam) ? "" : $valueparam, $value)),
9696
Relation::IN => $result[$pos] && in_array($valueparam, $value),
9797
Relation::NOT_IN => $result[$pos] && !in_array($valueparam, $value),
98+
Relation::IS_NULL => $result[$pos] && is_null($valueparam),
99+
Relation::IS_NOT_NULL => $result[$pos] && !is_null($valueparam),
98100
default => $result[$pos] && (str_contains(is_null($valueparam) ? "" : $valueparam, $value)),
99101
};
100102
}
@@ -125,7 +127,7 @@ public function addRelation(string $name, Relation $relation, mixed $value): sta
125127
* @return static
126128
* @desc Add a single string comparison to filter.
127129
*/
128-
public function and(string $name, Relation $relation, mixed $value): static
130+
public function and(string $name, Relation $relation, mixed $value = null): static
129131
{
130132
$this->filters[] = [" and ", $name, $relation, $value];
131133
return $this;

0 commit comments

Comments
 (0)