Code Duplication    Length = 13-16 lines in 6 locations

lib/Db/AccountsRequest.php 1 location

@@ 46-60 (lines=15) @@
43
	 * @return array
44
	 * @throws MemberDoesNotExistException
45
	 */
46
	public function getFromUserId(string $userId): array {
47
		$qb = $this->getAccountsSelectSql();
48
49
		$this->limitToDBField($qb, 'uid', $userId);
50
51
		$cursor = $qb->execute();
52
		$data = $cursor->fetch();
53
		$cursor->closeCursor();
54
55
		if ($data === false) {
56
			throw new MemberDoesNotExistException();
57
		}
58
59
		return $this->parseAccountsSelectSql($data);
60
	}
61
62
63
	/**

lib/Db/FederatedLinksRequest.php 1 location

@@ 208-221 (lines=14) @@
205
	 * @return FederatedLink
206
	 * @throws FederatedLinkDoesNotExistException
207
	 */
208
	public function getLinkFromId($linkUniqueId) {
209
		$qb = $this->getLinksSelectSql();
210
		$this->limitToUniqueId($qb, $linkUniqueId);
211
212
		$cursor = $qb->execute();
213
		$data = $cursor->fetch();
214
		$cursor->closeCursor();
215
216
		if ($data === false) {
217
			throw new FederatedLinkDoesNotExistException($this->l10n->t('Federated link not found'));
218
		}
219
220
		return $this->parseLinksSelectSql($data);
221
	}
222
223
224
}

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

@@ 474-488 (lines=15) @@
471
	 * @return Share
472
	 * @throws ShareNotFound
473
	 */
474
	public function getShareById($shareId, $recipientId = null) {
475
		$qb = $this->getBaseSelectSql();
476
477
		$this->limitToShare($qb, $shareId);
478
479
		$cursor = $qb->execute();
480
		$data = $cursor->fetch();
481
		$cursor->closeCursor();
482
483
		if ($data === false) {
484
			throw new ShareNotFound();
485
		}
486
487
		return $this->createShareObject($data);
488
	}
489
490
491
	/**

lib/Db/DeprecatedCirclesRequest.php 2 locations

@@ 115-130 (lines=16) @@
112
	 * @return null|DeprecatedCircle
113
	 * @throws CircleDoesNotExistException
114
	 */
115
	public function forceGetCircleByName($name) {
116
117
		$qb = $this->getCirclesSelectSql();
118
119
		$this->limitToName($qb, $name);
120
121
		$cursor = $qb->execute();
122
		$data = $cursor->fetch();
123
		$cursor->closeCursor();
124
125
		if ($data === false) {
126
			throw new CircleDoesNotExistException($this->l10n->t('Circle not found'));
127
		}
128
129
		return $this->parseCirclesSelectSql($data);
130
	}
131
132
133
	/**
@@ 358-371 (lines=14) @@
355
	 * @return DeprecatedCircle
356
	 * @throws CircleDoesNotExistException
357
	 */
358
	public function getCircleFromUniqueId($uniqueId) {
359
		$qb = $this->getCirclesSelectSql();
360
		$this->limitToUniqueId($qb, (string)$uniqueId);
361
362
		$cursor = $qb->execute();
363
		$data = $cursor->fetch();
364
		$cursor->closeCursor();
365
366
		if ($data === false) {
367
			throw new CircleDoesNotExistException($this->l10n->t('Circle not found'));
368
		}
369
370
		return $this->parseCirclesSelectSql($data);
371
	}
372
373
374
	/**