X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/93c677a6a955c75318c184d167737836c8c36cd5..refs/pull/5349/head:/app/Search/SearchOptionSet.php diff --git a/app/Search/SearchOptionSet.php b/app/Search/SearchOptionSet.php index 467dc9f5a..bd5e5a5b2 100644 --- a/app/Search/SearchOptionSet.php +++ b/app/Search/SearchOptionSet.php @@ -4,10 +4,13 @@ namespace BookStack\Search; use BookStack\Search\Options\SearchOption; +/** + * @template T of SearchOption + */ class SearchOptionSet { /** - * @var SearchOption[] + * @var T[] */ protected array $options = []; @@ -52,7 +55,7 @@ class SearchOptionSet } /** - * @return SearchOption[] + * @return T[] */ public function all(): array { @@ -60,10 +63,20 @@ class SearchOptionSet } /** - * @return SearchOption[] + * @return self */ - 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 + */ + public function nonNegated(): self + { + $values = array_values(array_filter($this->options, fn (SearchOption $option) => !$option->negated)); + return new self($values); } }