Completed
Pull Request — master (#546)
by Maxence
01:58
created

MemberRequest::getCircle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
6
/**
7
 * Circles - Bring cloud-users closer together.
8
 *
9
 * This file is licensed under the Affero General Public License version 3 or
10
 * later. See the COPYING file.
11
 *
12
 * @author Maxence Lange <[email protected]>
13
 * @copyright 2021
14
 * @license GNU AGPL version 3 or any later version
15
 *
16
 * This program is free software: you can redistribute it and/or modify
17
 * it under the terms of the GNU Affero General Public License as
18
 * published by the Free Software Foundation, either version 3 of the
19
 * License, or (at your option) any later version.
20
 *
21
 * This program is distributed in the hope that it will be useful,
22
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 * GNU Affero General Public License for more details.
25
 *
26
 * You should have received a copy of the GNU Affero General Public License
27
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
28
 *
29
 */
30
31
32
namespace OCA\Circles\Db;
33
34
35
use OCA\Circles\Exceptions\CircleNotFoundException;
36
use OCA\Circles\Model\Circle;
37
use OCA\Circles\Model\Member;
38
39
40
/**
41
 * Class MemberRequest
42
 *
43
 * @package OCA\Circles\Db
44
 */
45
class MemberRequest extends MemberRequestBuilder {
46
47
48
//	/**
49
//	 * @param Circle $circle
50
//	 */
51
//	public function save(Circle $circle): void {
52
//		$qb = $this->getCircleInsertSql();
53
//		$qb->setValue('id', $qb->createNamedParameter($circle->getId()));
54
////		   ->setValue('instance', $qb->createNamedParameter($circle->getInstance()))
55
////		   ->setValue('href', $qb->createNamedParameter($remote->getId()))
56
////		   ->setValue('item', $qb->createNamedParameter(json_encode($remote->getOrigData())));
57
//
58
//		$qb->execute();
59
//	}
60
//
61
62
//	/**
63
//	 * @param Circle $circle
64
//	 */
65
//	public function update(Circle $circle) {
66
//		$qb = $this->getCircleUpdateSql();
67
////		$qb->set('uid', $qb->createNamedParameter($circle->getUid(true)))
68
////		   ->set('href', $qb->createNamedParameter($circle->getId()))
69
////		   ->set('item', $qb->createNamedParameter(json_encode($circle->getOrigData())));
70
//
71
//		$qb->limitToUniqueId($circle->getId());
72
//
73
//		$qb->execute();
74
//	}
75
//
76
77
	/**
78
	 * @param Member|null $filter
0 ignored issues
show
Bug introduced by
There is no parameter named $filter. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
79
	 * @param Member|null $viewer
0 ignored issues
show
Bug introduced by
There is no parameter named $viewer. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
80
	 *
81
	 * @return Circle[]
82
	 */
83
	public function getMembers(string $circleId): array {
84
		$qb = $this->getMemberSelectSql();
85
		$qb->limitToCircleId($circleId);
86
87
		return $this->getItemsFromRequest($qb);
88
	}
89
90
91
	/**
92
	 * @param string $id
93
	 * @param Member|null $viewer
94
	 *
95
	 * @return Circle
96
	 * @throws CircleNotFoundException
97
	 */
98
	public function getCircle(string $id, ?Member $viewer = null): Circle {
99
		$qb = $this->getCircleSelectSql();
0 ignored issues
show
Bug introduced by
The method getCircleSelectSql() does not exist on OCA\Circles\Db\MemberRequest. Did you maybe mean getCircle()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
100
		$qb->limitToUniqueId($id);
101
		$qb->leftJoinOwner();
102
103
		if (!is_null($viewer)) {
104
			$qb->limitToViewer($viewer);
105
		}
106
107
		return $this->getItemFromRequest($qb);
108
	}
109
110
111
	/**
112
	 * @return Circle[]
113
	 */
114
	public function getFederated(): array {
115
		$qb = $this->getCircleSelectSql();
0 ignored issues
show
Bug introduced by
The method getCircleSelectSql() does not exist on OCA\Circles\Db\MemberRequest. Did you maybe mean getCircle()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
116
		$qb->filterConfig(Circle::CFG_FEDERATED);
117
		$qb->leftJoinOwner();
118
119
		return $this->getItemsFromRequest($qb);
120
	}
121
122
}
123
124