Code Duplication    Length = 15-20 lines in 8 locations

lib/Db/MembersRequest.php 2 locations

@@ 149-165 (lines=17) @@
146
	 * @return Member
147
	 * @throws MemberDoesNotExistException
148
	 */
149
	public function forceGetGroup($circleUniqueId, $groupId) {
150
		$qb = $this->getGroupsSelectSql();
151
152
		$this->limitToGroupId($qb, $groupId);
153
		$this->limitToCircleId($qb, $circleUniqueId);
154
155
		$cursor = $qb->execute();
156
		$data = $cursor->fetch();
157
		if ($data === false) {
158
			throw new MemberDoesNotExistException($this->l10n->t('This member does not exist'));
159
		}
160
161
		$group = $this->parseGroupsSelectSql($data);
162
		$cursor->closeCursor();
163
164
		return $group;
165
	}
166
167
168
	/**
@@ 53-71 (lines=19) @@
50
	 * @return Member
51
	 * @throws MemberDoesNotExistException
52
	 */
53
	public function forceGetMember($circleUniqueId, $userId, $type) {
54
		$qb = $this->getMembersSelectSql();
55
56
		$this->limitToUserId($qb, $userId);
57
		$this->limitToUserType($qb, $type);
58
		$this->limitToCircleId($qb, $circleUniqueId);
59
60
		$cursor = $qb->execute();
61
		$data = $cursor->fetch();
62
		$cursor->closeCursor();
63
64
		if ($data === false) {
65
			throw new MemberDoesNotExistException($this->l10n->t('This member does not exist'));
66
		}
67
68
		$member = $this->parseMembersSelectSql($data);
69
70
		return $member;
71
	}
72
73
74
	/**

lib/Db/CirclesRequest.php 3 locations

@@ 56-72 (lines=17) @@
53
	 * @return Circle
54
	 * @throws CircleDoesNotExistException
55
	 */
56
	public function forceGetCircle($circleUniqueId) {
57
		$qb = $this->getCirclesSelectSql();
58
59
		$this->limitToShortenUniqueId($qb, $circleUniqueId, Circle::SHORT_UNIQUE_ID_LENGTH);
60
61
		$cursor = $qb->execute();
62
		$data = $cursor->fetch();
63
		$cursor->closeCursor();
64
65
		if ($data === false) {
66
			throw new CircleDoesNotExistException($this->l10n->t('Circle not found'));
67
		}
68
69
		$entry = $this->parseCirclesSelectSql($data);
70
71
		return $entry;
72
	}
73
74
75
	/**
@@ 339-354 (lines=16) @@
336
	 * @return Circle
337
	 * @throws CircleDoesNotExistException
338
	 */
339
	public function getCircleFromUniqueId($uniqueId) {
340
		$qb = $this->getCirclesSelectSql();
341
		$this->limitToUniqueId($qb, (string)$uniqueId);
342
343
		$cursor = $qb->execute();
344
		$data = $cursor->fetch();
345
		$cursor->closeCursor();
346
347
		if ($data === false) {
348
			throw new CircleDoesNotExistException($this->l10n->t('Circle not found'));
349
		}
350
351
		$entry = $this->parseCirclesSelectSql($data);
352
353
		return $entry;
354
	}
355
356
357
	/**
@@ 364-383 (lines=20) @@
361
	 * @return SharingFrame
362
	 * @throws SharingFrameDoesNotExistException
363
	 */
364
	public function getFrame($circleUniqueId, $frameUniqueId) {
365
		$qb = $this->getSharesSelectSql();
366
		$this->limitToUniqueId($qb, $frameUniqueId);
367
		$this->limitToCircleId($qb, $circleUniqueId);
368
		$this->leftJoinCircle($qb);
369
370
		$cursor = $qb->execute();
371
		$data = $cursor->fetch();
372
		$cursor->closeCursor();
373
374
		if ($data === false) {
375
			throw new SharingFrameDoesNotExistException($this->l10n->t('Sharing Frame does not exist'));
376
		}
377
378
		$entry = $this->parseSharesSelectSql($data);
379
380
		return $entry;
381
	}
382
383
384
}

lib/Db/FederatedLinksRequest.php 3 locations

@@ 170-184 (lines=15) @@
167
	 * @return FederatedLink
168
	 * @throws FederatedLinkDoesNotExistException
169
	 */
170
	public function getLinkFromCircle($circleUniqueId, $linkUniqueId) {
171
		$qb = $this->getLinksSelectSql();
172
		$this->limitToCircleId($qb, $circleUniqueId);
173
		$this->limitToUniqueId($qb, $linkUniqueId);
174
175
		$cursor = $qb->execute();
176
		$data = $cursor->fetch();
177
		$cursor->closeCursor();
178
179
		if ($data === false) {
180
			throw new FederatedLinkDoesNotExistException($this->l10n->t('Federated link not found'));
181
		}
182
183
		return $this->parseLinksSelectSql($data);
184
	}
185
186
187
	/**
@@ 196-210 (lines=15) @@
193
	 * @return FederatedLink
194
	 * @throws FederatedLinkDoesNotExistException
195
	 */
196
	public function getLinkFromToken($token, $uniqueId) {
197
		$qb = $this->getLinksSelectSql();
198
		$this->limitToUniqueId($qb, (string)$uniqueId);
199
		$this->limitToToken($qb, (string)$token);
200
201
		$cursor = $qb->execute();
202
		$data = $cursor->fetch();
203
		$cursor->closeCursor();
204
205
		if ($data === false) {
206
			throw new FederatedLinkDoesNotExistException($this->l10n->t('Federated link not found'));
207
		}
208
209
		return $this->parseLinksSelectSql($data);
210
	}
211
212
213
	/**
@@ 221-236 (lines=16) @@
218
	 * @return FederatedLink
219
	 * @throws FederatedLinkDoesNotExistException
220
	 */
221
	public function getLinkFromId($linkUniqueId) {
222
		$qb = $this->getLinksSelectSql();
223
		$this->limitToShortenUniqueId($qb, $linkUniqueId, FederatedLink::SHORT_UNIQUE_ID_LENGTH);
224
225
		$cursor = $qb->execute();
226
		$data = $cursor->fetch();
227
		$cursor->closeCursor();
228
229
		if ($data === false) {
230
			throw new FederatedLinkDoesNotExistException($this->l10n->t('Federated link not found'));
231
		}
232
233
		$entry = $this->parseLinksSelectSql($data);
234
235
		return $entry;
236
	}
237
238
239
}