Skip to content
This repository was archived by the owner on Oct 15, 2025. It is now read-only.

Commit cda7bb9

Browse files
author
Flo Faber
committed
Allow Filter to have empty tag and operator in constructor.
1 parent 42f4e85 commit cda7bb9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Filter.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,29 @@ class Filter
2626

2727

2828
/**
29-
* Creates a new filter.
29+
* Creates a new filter. If $tag or $operator is empty, an empty Filter is returned.
3030
* @param string $tag Tag to be searched for. Like artist, title,...
3131
* @param string $operator Comparison operator. Like ==, contains, ~=,...
3232
* @param string $value The value to search for. Unescaped.
3333
*/
34-
public function __construct(string $tag, string $operator, string $value)
34+
public function __construct(string $tag = "", string $operator = "", string $value = "")
3535
{
3636
$this->and($tag, $operator, $value);
3737
}
3838

3939

4040
/**
41-
* Used to chain multiple filters together with a logical AND.
41+
* Used to chain multiple filters together with a logical AND. If $tag or $operator is empty, the condition is not added to the Filter.
4242
* @param string $tag
4343
* @param string $operator
4444
* @param string $value
4545
* @return $this
4646
*/
4747
public function and(string $tag, string $operator, string $value): Filter
4848
{
49+
50+
if($tag === "" || $operator === ""){ return $this; }
51+
4952
if($value === ""){
5053
$value = "''";
5154
}else{

0 commit comments

Comments
 (0)