Passed
Push — master ( a4d511...6fbf8f )
by Morris
20:15 queued 11s
created

UserStatusProvider::getUserStatuses()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 9
rs 10
c 1
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 AGPL-3.0
11
 *
12
 * This code is free software: you can redistribute it and/or modify
13
 * it under the terms of the GNU Affero General Public License, version 3,
14
 * as published by the Free Software Foundation.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
 * GNU Affero General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU Affero General Public License, version 3,
22
 * along with this program. If not, see <http://www.gnu.org/licenses/>
23
 *
24
 */
25
namespace OCA\UserStatus\Connector;
26
27
use OCA\UserStatus\Service\StatusService;
28
use OCP\UserStatus\IProvider;
29
30
class UserStatusProvider implements IProvider {
31
32
	/** @var StatusService */
33
	private $service;
34
35
	/**
36
	 * UserStatusProvider constructor.
37
	 *
38
	 * @param StatusService $service
39
	 */
40
	public function __construct(StatusService $service) {
41
		$this->service = $service;
42
	}
43
44
	/**
45
	 * @inheritDoc
46
	 */
47
	public function getUserStatuses(array $userIds): array {
48
		$statuses = $this->service->findByUserIds($userIds);
49
50
		$userStatuses = [];
51
		foreach ($statuses as $status) {
52
			$userStatuses[$status->getUserId()] = new UserStatus($status);
53
		}
54
55
		return $userStatuses;
56
	}
57
}
58