Passed
Push — master ( 98fd66...bf4acd )
by Joas
18:11 queued 12s
created

UserStatusProvider::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @copyright Copyright (c) 2020, Georg Ehrke
7
 *
8
 * @author Georg Ehrke <[email protected]>
9
 *
10
 * @license GNU AGPL version 3 or any later version
11
 *
12
 * This program is free software: you can redistribute it and/or modify
13
 * it under the terms of the GNU Affero General Public License as
14
 * published by the Free Software Foundation, either version 3 of the
15
 * License, or (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
 * GNU Affero General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU Affero General Public License
23
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24
 *
25
 */
26
namespace OCA\UserStatus\Connector;
27
28
use OCA\UserStatus\Service\StatusService;
29
use OCP\UserStatus\IProvider;
30
use OC\UserStatus\ISettableProvider;
31
32
class UserStatusProvider implements IProvider, ISettableProvider {
33
34
	/** @var StatusService */
35
	private $service;
36
37
	/**
38
	 * UserStatusProvider constructor.
39
	 *
40
	 * @param StatusService $service
41
	 */
42
	public function __construct(StatusService $service) {
43
		$this->service = $service;
44
	}
45
46
	/**
47
	 * @inheritDoc
48
	 */
49
	public function getUserStatuses(array $userIds): array {
50
		$statuses = $this->service->findByUserIds($userIds);
51
52
		$userStatuses = [];
53
		foreach ($statuses as $status) {
54
			$userStatuses[$status->getUserId()] = new UserStatus($status);
55
		}
56
57
		return $userStatuses;
58
	}
59
60
	public function setUserStatus(string $userId, string $messageId, string $status, bool $createBackup): void {
61
		$this->service->setUserStatus($userId, $status, $messageId, $createBackup);
62
	}
63
64
	public function revertUserStatus(string $userId, string $messageId, string $status): void {
65
		$this->service->revertUserStatus($userId, $messageId, $status);
66
	}
67
68
	public function revertMultipleUserStatus(array $userIds, string $messageId, string $status): void {
69
		$this->service->revertMultipleUserStatus($userIds, $messageId, $status);
70
	}
71
}
72