Code Duplication    Length = 13-18 lines in 5 locations

lib/Db/TokensRequest.php 1 location

@@ 51-63 (lines=13) @@
48
	 * @return SharesToken
49
	 * @throws TokenDoesNotExistException
50
	 */
51
	public function getByToken(string $token) {
52
		$qb = $this->getTokensSelectSql();
53
		$this->limitToToken($qb, $token);
54
55
		$cursor = $qb->execute();
56
		$data = $cursor->fetch();
57
		$cursor->closeCursor();
58
		if ($data === false) {
59
			throw new TokenDoesNotExistException('Unknown share token');
60
		}
61
62
		return $this->parseTokensSelectSql($data);
63
	}
64
65
66
	/**

lib/ShareByCircleProvider.php 1 location

@@ 434-448 (lines=15) @@
431
	 * @return Share
432
	 * @throws ShareNotFound
433
	 */
434
	public function getShareById($shareId, $recipientId = null) {
435
		$qb = $this->getBaseSelectSql();
436
437
		$this->limitToShare($qb, $shareId);
438
439
		$cursor = $qb->execute();
440
		$data = $cursor->fetch();
441
		$cursor->closeCursor();
442
443
		if ($data === false) {
444
			throw new ShareNotFound();
445
		}
446
447
		return $this->createShareObject($data);
448
	}
449
450
451
	/**

lib/Db/CirclesRequest.php 3 locations

@@ 53-70 (lines=18) @@
50
	 * @return Circle
51
	 * @throws CircleDoesNotExistException
52
	 */
53
	public function forceGetCircle($circleUniqueId) {
54
		$qb = $this->getCirclesSelectSql();
55
56
		$this->leftJoinOwner($qb, '');
57
		$this->limitToShortenUniqueId($qb, $circleUniqueId, Circle::SHORT_UNIQUE_ID_LENGTH);
58
59
		$cursor = $qb->execute();
60
		$data = $cursor->fetch();
61
		$cursor->closeCursor();
62
63
		if ($data === false) {
64
			throw new CircleDoesNotExistException($this->l10n->t('Circle not found'));
65
		}
66
67
		$entry = $this->parseCirclesSelectSql($data);
68
69
		return $entry;
70
	}
71
72
73
	/**
@@ 113-130 (lines=18) @@
110
	 * @return null|Circle
111
	 * @throws CircleDoesNotExistException
112
	 */
113
	public function forceGetCircleByName($name) {
114
115
		$qb = $this->getCirclesSelectSql();
116
117
		$this->limitToName($qb, $name);
118
119
		$cursor = $qb->execute();
120
		$data = $cursor->fetch();
121
		$cursor->closeCursor();
122
123
		if ($data === false) {
124
			throw new CircleDoesNotExistException($this->l10n->t('Circle not found'));
125
		}
126
127
		$entry = $this->parseCirclesSelectSql($data);
128
129
		return $entry;
130
	}
131
132
133
	/**
@@ 377-392 (lines=16) @@
374
	 * @return Circle
375
	 * @throws CircleDoesNotExistException
376
	 */
377
	public function getCircleFromUniqueId($uniqueId) {
378
		$qb = $this->getCirclesSelectSql();
379
		$this->limitToUniqueId($qb, (string)$uniqueId);
380
381
		$cursor = $qb->execute();
382
		$data = $cursor->fetch();
383
		$cursor->closeCursor();
384
385
		if ($data === false) {
386
			throw new CircleDoesNotExistException($this->l10n->t('Circle not found'));
387
		}
388
389
		$entry = $this->parseCirclesSelectSql($data);
390
391
		return $entry;
392
	}
393
394
395
	/**