Skip to content

Commit

Permalink
Allow Filter to have empty tag and operator in constructor.
Browse files Browse the repository at this point in the history
  • Loading branch information
Flo Faber committed Sep 14, 2024
1 parent 42f4e85 commit cda7bb9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,29 @@ class Filter


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


/**
* Used to chain multiple filters together with a logical AND.
* Used to chain multiple filters together with a logical AND. If $tag or $operator is empty, the condition is not added to the Filter.
* @param string $tag
* @param string $operator
* @param string $value
* @return $this
*/
public function and(string $tag, string $operator, string $value): Filter
{

if($tag === "" || $operator === ""){ return $this; }

if($value === ""){
$value = "''";
}else{
Expand Down

0 comments on commit cda7bb9

Please sign in to comment.