Code Duplication    Length = 14-25 lines in 5 locations

lib/Db/CirclesRequest.php 4 locations

@@ 57-70 (lines=14) @@
54
	 * @return Circle
55
	 * @throws CircleDoesNotExistException
56
	 */
57
	public function forceGetCircle($circleId) {
58
		$qb = $this->getCirclesSelectSql();
59
		$this->limitToId($qb, $circleId);
60
		$cursor = $qb->execute();
61
62
		$data = $cursor->fetch();
63
		if ($data === false || $data === null) {
64
			throw new CircleDoesNotExistException($this->l10n->t('Circle not found'));
65
		}
66
67
		$entry = $this->parseCirclesSelectSql($data);
68
69
		return $entry;
70
	}
71
72
73
	/**
@@ 82-106 (lines=25) @@
79
	 * @throws CircleDoesNotExistException
80
	 */
81
	// TODO: Filters data
82
	public function getCircle($circleId, $userId) {
83
		$qb = $this->getCirclesSelectSql();
84
85
		$this->limitToId($qb, $circleId);
86
		$this->leftJoinUserIdAsViewer($qb, $userId);
87
88
89
//		$this->leftjoinOwner($qb);
90
//		$this->buildWithMemberLevel($qb, 'u.level', $level);
91
//		$this->buildWithCircleId($qb, 'c.id', $circleId);
92
//		$this->buildWithOrXTypes($qb, $userId, $type, $name, $circleId);
93
94
		$cursor = $qb->execute();
95
		$data = $cursor->fetch();
96
		if ($data === false || $data === null) {
97
			throw new CircleDoesNotExistException(
98
				$this->l10n->t('Circle not found')
99
			);
100
		}
101
102
		$circle = $this->parseCirclesSelectSql($data);
103
104
//		if ($circle->getUser()->getLevel)
105
		return $circle;
106
	}
107
108
109
	/**
@@ 210-228 (lines=19) @@
207
	 * @return FederatedLink
208
	 * @throws FederatedLinkDoesNotExistException
209
	 */
210
	public function getLinkFromToken($token, $uniqueId) {
211
		$qb = $this->getLinksSelectSql();
212
		$this->limitToUniqueId($qb, (string)$uniqueId);
213
		$this->limitToToken($qb, (string)$token);
214
215
		$cursor = $qb->execute();
216
		$data = $cursor->fetch();
217
218
		if ($data === false || $data === null) {
219
			throw new FederatedLinkDoesNotExistException(
220
				$this->l10n->t('Federated Link not found')
221
			);
222
		}
223
224
		$entry = $this->parseLinksSelectSql($data);
225
		$cursor->closeCursor();
226
227
		return $entry;
228
	}
229
230
231
	/**
@@ 239-256 (lines=18) @@
236
	 * @return FederatedLink
237
	 * @throws FederatedLinkDoesNotExistException
238
	 */
239
	public function getLinkFromId($linkId) {
240
		$qb = $this->getLinksSelectSql();
241
		$this->limitToId($qb, (string)$linkId);
242
243
		$cursor = $qb->execute();
244
		$data = $cursor->fetch();
245
		$cursor->closeCursor();
246
247
		if ($data === false || $data === null) {
248
			throw new FederatedLinkDoesNotExistException(
249
				$this->l10n->t('Federated Link not found')
250
			);
251
		}
252
253
		$entry = $this->parseLinksSelectSql($data);
254
255
		return $entry;
256
	}
257
258
259
	/**

lib/Db/MembersRequest.php 1 location

@@ 59-75 (lines=17) @@
56
	 * @return Member
57
	 * @throws MemberDoesNotExistException
58
	 */
59
	public function forceGetGroup($circleId, $groupId) {
60
		$qb = $this->getGroupsSelectSql();
61
62
		$this->limitToGroupId($qb, $groupId);
63
		$this->limitToCircleId($qb, $circleId);
64
65
		$cursor = $qb->execute();
66
		$data = $cursor->fetch();
67
		if ($data === false) {
68
			throw new MemberDoesNotExistException($this->l10n->t('This member does not exist'));
69
		}
70
71
		$group = Member::fromArray($this->l10n, $data);
72
		$cursor->closeCursor();
73
74
		return $group;
75
	}
76
77
78
	// TODO - returns data of a group from a Viewer POV