Completed
Push — master ( 138f00...e3741d )
by Maxence
16s queued 10s
created

AccountsRequest::getFromUserId()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15

Duplication

Lines 15
Ratio 100 %

Importance

Changes 0
Metric Value
dl 15
loc 15
rs 9.7666
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
/**
3
 * Circles - Bring cloud-users closer together.
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Maxence Lange <[email protected]>
9
 * @copyright 2017
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
27
28
namespace OCA\Circles\Db;
29
30
31
use daita\MySmallPhpTools\Traits\TStringTools;
32
use OCA\Circles\Exceptions\MemberDoesNotExistException;
33
34
class AccountsRequest extends AccountsRequestBuilder {
35
36
37
	use TStringTools;
38
39
40
	/**
41
	 * @param string $userId
42
	 *
43
	 * @return array
44
	 * @throws MemberDoesNotExistException
45
	 */
46 View Code Duplication
	public function getFromUserId(string $userId): array {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
47
		$qb = $this->getAccountsSelectSql();
48
49
		$this->limitToDBField($qb, 'uid', $userId);
50
51
		$cursor = $qb->execute();
52
		$data = $cursor->fetch();
53
		$cursor->closeCursor();
54
55
		if ($data === false) {
56
			throw new MemberDoesNotExistException();
57
		}
58
59
		return $this->parseAccountsSelectSql($data);
60
	}
61
62
63
	/**
64
	 * @return array
65
	 */
66 View Code Duplication
	public function getAll(): array {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
67
		$qb = $this->getAccountsSelectSql();
68
69
		$accounts = [];
70
		$cursor = $qb->execute();
71
		while ($data = $cursor->fetch()) {
72
			$account = $this->parseAccountsSelectSql($data);
73
			$accounts[$account['userId']] = $account;
74
		}
75
		$cursor->closeCursor();
76
77
		return $accounts;
78
	}
79
80
}
81