Code Duplication    Length = 16-19 lines in 6 locations

lib/Db/CirclesRequest.php 4 locations

@@ 344-359 (lines=16) @@
341
	 * @return Circle
342
	 * @throws CircleDoesNotExistException
343
	 */
344
	public function getCircleFromUniqueId($uniqueId) {
345
		$qb = $this->getCirclesSelectSql();
346
		$this->limitToUniqueId($qb, (string)$uniqueId);
347
348
		$cursor = $qb->execute();
349
		$data = $cursor->fetch();
350
		$cursor->closeCursor();
351
352
		if ($data === false) {
353
			throw new CircleDoesNotExistException($this->l10n->t('Circle not found'));
354
		}
355
356
		$entry = $this->parseCirclesSelectSql($data);
357
358
		return $entry;
359
	}
360
361
362
	/**
@@ 369-385 (lines=17) @@
366
	 * @return SharingFrame
367
	 * @throws SharingFrameDoesNotEXist
368
	 */
369
	public function getFrame($circleId, $uniqueId) {
370
		$qb = $this->getSharesSelectSql();
371
		$this->limitToUniqueId($qb, (string)$uniqueId);
372
		$this->limitToCircleId($qb, (int)$circleId);
373
374
		$cursor = $qb->execute();
375
		$data = $cursor->fetch();
376
		$cursor->closeCursor();
377
378
		if ($data === false) {
379
			throw new SharingFrameDoesNotEXist($this->l10n->t('Sharing Frame does not exist'));
380
		}
381
382
		$entry = $this->parseSharesSelectSql($data);
383
384
		return $entry;
385
	}
386
387
388
	/**
@@ 397-415 (lines=19) @@
394
	 * @return FederatedLink
395
	 * @throws FederatedLinkDoesNotExistException
396
	 */
397
	public function getLinkFromToken($token, $uniqueId) {
398
		$qb = $this->getLinksSelectSql();
399
		$this->limitToUniqueId($qb, (string)$uniqueId);
400
		$this->limitToToken($qb, (string)$token);
401
402
		$cursor = $qb->execute();
403
		$data = $cursor->fetch();
404
		$cursor->closeCursor();
405
406
		if ($data === false) {
407
			throw new FederatedLinkDoesNotExistException(
408
				$this->l10n->t('Federated Link not found')
409
			);
410
		}
411
412
		$entry = $this->parseLinksSelectSql($data);
413
414
		return $entry;
415
	}
416
417
418
	/**
@@ 426-443 (lines=18) @@
423
	 * @return FederatedLink
424
	 * @throws FederatedLinkDoesNotExistException
425
	 */
426
	public function getLinkFromId($linkId) {
427
		$qb = $this->getLinksSelectSql();
428
		$this->limitToId($qb, (string)$linkId);
429
430
		$cursor = $qb->execute();
431
		$data = $cursor->fetch();
432
		$cursor->closeCursor();
433
434
		if ($data === false) {
435
			throw new FederatedLinkDoesNotExistException(
436
				$this->l10n->t('Federated Link not found')
437
			);
438
		}
439
440
		$entry = $this->parseLinksSelectSql($data);
441
442
		return $entry;
443
	}
444
445
446
	/**

lib/Db/MembersRequest.php 2 locations

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