Code Duplication    Length = 16-20 lines in 7 locations

lib/Db/CirclesRequest.php 5 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);
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
	/**
@@ 347-362 (lines=16) @@
344
	 * @return Circle
345
	 * @throws CircleDoesNotExistException
346
	 */
347
	public function getCircleFromUniqueId($uniqueId) {
348
		$qb = $this->getCirclesSelectSql();
349
		$this->limitToUniqueId($qb, (string)$uniqueId);
350
351
		$cursor = $qb->execute();
352
		$data = $cursor->fetch();
353
		$cursor->closeCursor();
354
355
		if ($data === false) {
356
			throw new CircleDoesNotExistException($this->l10n->t('Circle not found'));
357
		}
358
359
		$entry = $this->parseCirclesSelectSql($data);
360
361
		return $entry;
362
	}
363
364
365
	/**
@@ 372-391 (lines=20) @@
369
	 * @return SharingFrame
370
	 * @throws SharingFrameDoesNotExistException
371
	 */
372
	public function getFrame($circleUniqueId, $frameUniqueId) {
373
		$qb = $this->getSharesSelectSql();
374
		$this->limitToUniqueId($qb, $frameUniqueId);
375
		$this->limitToCircleId($qb, $circleUniqueId);
376
		$this->leftJoinCircle($qb);
377
378
		$cursor = $qb->execute();
379
		$data = $cursor->fetch();
380
		$cursor->closeCursor();
381
382
		if ($data === false) {
383
			throw new SharingFrameDoesNotExistException(
384
				$this->l10n->t('Sharing Frame does not exist')
385
			);
386
		}
387
388
		$entry = $this->parseSharesSelectSql($data);
389
390
		return $entry;
391
	}
392
393
394
	/**
@@ 403-421 (lines=19) @@
400
	 * @return FederatedLink
401
	 * @throws FederatedLinkDoesNotExistException
402
	 */
403
	public function getLinkFromToken($token, $uniqueId) {
404
		$qb = $this->getLinksSelectSql();
405
		$this->limitToUniqueId($qb, (string)$uniqueId);
406
		$this->limitToToken($qb, (string)$token);
407
408
		$cursor = $qb->execute();
409
		$data = $cursor->fetch();
410
		$cursor->closeCursor();
411
412
		if ($data === false) {
413
			throw new FederatedLinkDoesNotExistException(
414
				$this->l10n->t('Federated link not found')
415
			);
416
		}
417
418
		$entry = $this->parseLinksSelectSql($data);
419
420
		return $entry;
421
	}
422
423
424
	/**
@@ 432-449 (lines=18) @@
429
	 * @return FederatedLink
430
	 * @throws FederatedLinkDoesNotExistException
431
	 */
432
	public function getLinkFromId($linkId) {
433
		$qb = $this->getLinksSelectSql();
434
		$this->limitToId($qb, (string)$linkId);
435
436
		$cursor = $qb->execute();
437
		$data = $cursor->fetch();
438
		$cursor->closeCursor();
439
440
		if ($data === false) {
441
			throw new FederatedLinkDoesNotExistException(
442
				$this->l10n->t('Federated link not found')
443
			);
444
		}
445
446
		$entry = $this->parseLinksSelectSql($data);
447
448
		return $entry;
449
	}
450
451
452
	/**

lib/Db/MembersRequest.php 2 locations

@@ 152-168 (lines=17) @@
149
	 * @return Member
150
	 * @throws MemberDoesNotExistException
151
	 */
152
	public function forceGetGroup($circleUniqueId, $groupId) {
153
		$qb = $this->getGroupsSelectSql();
154
155
		$this->limitToGroupId($qb, $groupId);
156
		$this->limitToCircleId($qb, $circleUniqueId);
157
158
		$cursor = $qb->execute();
159
		$data = $cursor->fetch();
160
		if ($data === false) {
161
			throw new MemberDoesNotExistException($this->l10n->t('This member does not exist'));
162
		}
163
164
		$group = $this->parseGroupsSelectSql($data);
165
		$cursor->closeCursor();
166
167
		return $group;
168
	}
169
170
171
	/**
@@ 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
	/**