use BookStack\Search\Options\SearchOption;
+/**
+ * @template T of SearchOption
+ */
class SearchOptionSet
{
/**
- * @var SearchOption[]
+ * @var T[]
*/
protected array $options = [];
}
/**
- * @return SearchOption[]
+ * @return T[]
*/
public function all(): array
{
}
/**
- * @return SearchOption[]
+ * @return self<T>
*/
- public function negated(): array
+ public function negated(): self
{
- return array_values(array_filter($this->options, fn (SearchOption $option) => $option->negated));
+ $values = array_values(array_filter($this->options, fn (SearchOption $option) => $option->negated));
+ return new self($values);
+ }
+
+ /**
+ * @return self<T>
+ */
+ public function nonNegated(): self
+ {
+ $values = array_values(array_filter($this->options, fn (SearchOption $option) => !$option->negated));
+ return new self($values);
}
}