Code Duplication    Length = 14-16 lines in 7 locations

lib/Db/CirclesRequest.php 3 locations

@@ 57-72 (lines=16) @@
54
	 * @return Circle
55
	 * @throws CircleDoesNotExistException
56
	 */
57
	public function forceGetCircle($circleUniqueId, bool $allSettings = false) {
58
		$qb = $this->getCirclesSelectSql();
59
60
		$this->leftJoinOwner($qb, '');
61
		$this->limitToUniqueId($qb, $circleUniqueId);
62
63
		$cursor = $qb->execute();
64
		$data = $cursor->fetch();
65
		$cursor->closeCursor();
66
67
		if ($data === false) {
68
			throw new CircleDoesNotExistException($this->l10n->t('Circle not found'));
69
		}
70
71
		return $this->parseCirclesSelectSql($data, $allSettings);
72
	}
73
74
75
	/**
@@ 115-130 (lines=16) @@
112
	 * @return null|Circle
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
	/**
@@ 418-432 (lines=15) @@
415
	 * @return Circle
416
	 * @throws CircleDoesNotExistException
417
	 */
418
	public function getFromContactGroup(int $addressBookId, string $group): Circle {
419
		$qb = $this->getCirclesSelectSql();
420
		$this->limitToAddressBookId($qb, $addressBookId);
421
		$this->limitToContactGroup($qb, $group);
422
423
		$cursor = $qb->execute();
424
		$data = $cursor->fetch();
425
		$cursor->closeCursor();
426
427
		if ($data === false) {
428
			throw new CircleDoesNotExistException($this->l10n->t('Circle not found'));
429
		}
430
431
		return $this->parseCirclesSelectSql($data);
432
	}
433
434
}
435

lib/Db/FederatedLinksRequest.php 3 locations

@@ 157-171 (lines=15) @@
154
	 * @return FederatedLink
155
	 * @throws FederatedLinkDoesNotExistException
156
	 */
157
	public function getLinkFromCircle($circleUniqueId, $linkUniqueId) {
158
		$qb = $this->getLinksSelectSql();
159
		$this->limitToCircleId($qb, $circleUniqueId);
160
		$this->limitToUniqueId($qb, $linkUniqueId);
161
162
		$cursor = $qb->execute();
163
		$data = $cursor->fetch();
164
		$cursor->closeCursor();
165
166
		if ($data === false) {
167
			throw new FederatedLinkDoesNotExistException($this->l10n->t('Federated link not found'));
168
		}
169
170
		return $this->parseLinksSelectSql($data);
171
	}
172
173
174
	/**
@@ 183-197 (lines=15) @@
180
	 * @return FederatedLink
181
	 * @throws FederatedLinkDoesNotExistException
182
	 */
183
	public function getLinkFromToken($token, $uniqueId) {
184
		$qb = $this->getLinksSelectSql();
185
		$this->limitToUniqueId($qb, (string)$uniqueId);
186
		$this->limitToToken($qb, (string)$token);
187
188
		$cursor = $qb->execute();
189
		$data = $cursor->fetch();
190
		$cursor->closeCursor();
191
192
		if ($data === false) {
193
			throw new FederatedLinkDoesNotExistException($this->l10n->t('Federated link not found'));
194
		}
195
196
		return $this->parseLinksSelectSql($data);
197
	}
198
199
200
	/**
@@ 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/SharingFrameRequest.php 1 location

@@ 44-59 (lines=16) @@
41
	 * @return SharingFrame
42
	 * @throws SharingFrameDoesNotExistException
43
	 */
44
	public function getSharingFrame($circleUniqueId, $frameUniqueId) {
45
		$qb = $this->getSharesSelectSql();
46
		$this->limitToUniqueId($qb, $frameUniqueId);
47
		$this->limitToCircleId($qb, $circleUniqueId);
48
		$this->leftJoinCircle($qb);
49
50
		$cursor = $qb->execute();
51
		$data = $cursor->fetch();
52
		$cursor->closeCursor();
53
54
		if ($data === false) {
55
			throw new SharingFrameDoesNotExistException($this->l10n->t('Sharing Frame does not exist'));
56
		}
57
58
		return $this->parseSharesSelectSql($data);
59
	}
60
61
62
	/**