aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Search/Filter/UserFilter.php
blob: 4f2061a4ba6f42d94d7bc1c415b268b65e1429ae (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\IUser;
use OCP\IUserManager;
use OCP\Search\IFilter;

class UserFilter implements IFilter {
	private IUser $user;

	public function __construct(
		string $value,
		IUserManager $userManager,
	) {
		$user = $userManager->get($value);
		if ($user === null) {
			throw new InvalidArgumentException('User ' . $value . ' not found');
		}
		$this->user = $user;
	}

	public function get(): IUser {
		return $this->user;
	}
}