aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Search/Filter/StringsFilter.php
blob: 8b8fabb53474eec116375690b5de8bbf0ed256b6 (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
<?php

declare(strict_types=1);

/**
 * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

namespace OC\Search\Filter;

use InvalidArgumentException;
use OCP\Search\IFilter;

class StringsFilter implements IFilter {
	/**
	 * @var string[]
	 */
	private array $values;

	public function __construct(string ...$values) {
		$this->values = array_unique(array_filter($values));
		if (empty($this->values)) {
			throw new InvalidArgumentException('Strings filter can’t be empty');
		}
	}

	/**
	 * @return string[]
	 */
	public function get(): array {
		return $this->values;
	}
}