Code Duplication    Length = 16-19 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
	/**
@@ 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
	/**

lib/Db/MembersRequest.php 2 locations

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