Code Duplication    Length = 16-19 lines in 7 locations

lib/Db/MembersRequest.php 2 locations

@@ 51-68 (lines=18) @@
48
	 * @return Member
49
	 * @throws MemberDoesNotExistException
50
	 */
51
	public function forceGetMember($circleUniqueId, $userId) {
52
		$qb = $this->getMembersSelectSql();
53
54
		$this->limitToUserId($qb, $userId);
55
		$this->limitToCircleId($qb, $circleUniqueId);
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($circleUniqueId, $groupId) {
149
		$qb = $this->getGroupsSelectSql();
150
151
		$this->limitToGroupId($qb, $groupId);
152
		$this->limitToCircleId($qb, $circleUniqueId);
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
	/**

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
	/**
@@ 338-353 (lines=16) @@
335
	 * @return Circle
336
	 * @throws CircleDoesNotExistException
337
	 */
338
	public function getCircleFromUniqueId($uniqueId) {
339
		$qb = $this->getCirclesSelectSql();
340
		$this->limitToUniqueId($qb, (string)$uniqueId);
341
342
		$cursor = $qb->execute();
343
		$data = $cursor->fetch();
344
		$cursor->closeCursor();
345
346
		if ($data === false) {
347
			throw new CircleDoesNotExistException($this->l10n->t('Circle not found'));
348
		}
349
350
		$entry = $this->parseCirclesSelectSql($data);
351
352
		return $entry;
353
	}
354
355
356
	/**
@@ 363-379 (lines=17) @@
360
	 * @return SharingFrame
361
	 * @throws SharingFrameDoesNotExistException
362
	 */
363
	public function getFrame($circleUniqueId, $frameUniqueId) {
364
		$qb = $this->getSharesSelectSql();
365
		$this->limitToUniqueId($qb, $frameUniqueId);
366
		$this->limitToCircleId($qb, $circleUniqueId);
367
368
		$cursor = $qb->execute();
369
		$data = $cursor->fetch();
370
		$cursor->closeCursor();
371
372
		if ($data === false) {
373
			throw new SharingFrameDoesNotExistException($this->l10n->t('Sharing Frame does not exist'));
374
		}
375
376
		$entry = $this->parseSharesSelectSql($data);
377
378
		return $entry;
379
	}
380
381
382
	/**
@@ 391-409 (lines=19) @@
388
	 * @return FederatedLink
389
	 * @throws FederatedLinkDoesNotExistException
390
	 */
391
	public function getLinkFromToken($token, $uniqueId) {
392
		$qb = $this->getLinksSelectSql();
393
		$this->limitToUniqueId($qb, (string)$uniqueId);
394
		$this->limitToToken($qb, (string)$token);
395
396
		$cursor = $qb->execute();
397
		$data = $cursor->fetch();
398
		$cursor->closeCursor();
399
400
		if ($data === false) {
401
			throw new FederatedLinkDoesNotExistException(
402
				$this->l10n->t('Federated link not found')
403
			);
404
		}
405
406
		$entry = $this->parseLinksSelectSql($data);
407
408
		return $entry;
409
	}
410
411
412
	/**
@@ 420-437 (lines=18) @@
417
	 * @return FederatedLink
418
	 * @throws FederatedLinkDoesNotExistException
419
	 */
420
	public function getLinkFromId($linkId) {
421
		$qb = $this->getLinksSelectSql();
422
		$this->limitToId($qb, (string)$linkId);
423
424
		$cursor = $qb->execute();
425
		$data = $cursor->fetch();
426
		$cursor->closeCursor();
427
428
		if ($data === false) {
429
			throw new FederatedLinkDoesNotExistException(
430
				$this->l10n->t('Federated link not found')
431
			);
432
		}
433
434
		$entry = $this->parseLinksSelectSql($data);
435
436
		return $entry;
437
	}
438
439
440
	/**