blob: 173c967245abe53f0fcdcbd796dcb55ea16a0b8c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OC\Search;
use Generator;
use OCP\Search\IFilter;
use OCP\Search\IFilterCollection;
/**
* Interface for search filters
*
* @since 28.0.0
*/
class FilterCollection implements IFilterCollection {
/**
* @var IFilter[]
*/
private array $filters;
public function __construct(IFilter ...$filters) {
$this->filters = $filters;
}
public function has(string $name): bool {
return isset($this->filters[$name]);
}
public function get(string $name): ?IFilter {
return $this->filters[$name] ?? null;
}
public function getIterator(): Generator {
foreach ($this->filters as $k => $v) {
yield $k => $v;
}
}
}
|