Code Duplication    Length = 15-20 lines in 7 locations

lib/Db/MembersRequest.php 2 locations

@@ 53-71 (lines=19) @@
50
	 * @return Member
51
	 * @throws MemberDoesNotExistException
52
	 */
53
	public function forceGetMember($circleUniqueId, $userId, $type) {
54
		$qb = $this->getMembersSelectSql();
55
56
		$this->limitToUserId($qb, $userId);
57
		$this->limitToUserType($qb, $type);
58
		$this->limitToCircleId($qb, $circleUniqueId);
59
60
		$cursor = $qb->execute();
61
		$data = $cursor->fetch();
62
		$cursor->closeCursor();
63
64
		if ($data === false) {
65
			throw new MemberDoesNotExistException($this->l10n->t('This member does not exist'));
66
		}
67
68
		$member = $this->parseMembersSelectSql($data);
69
70
		return $member;
71
	}
72
73
74
	/**
@@ 174-190 (lines=17) @@
171
	 * @return Member
172
	 * @throws MemberDoesNotExistException
173
	 */
174
	public function forceGetGroup($circleUniqueId, $groupId) {
175
		$qb = $this->getGroupsSelectSql();
176
177
		$this->limitToGroupId($qb, $groupId);
178
		$this->limitToCircleId($qb, $circleUniqueId);
179
180
		$cursor = $qb->execute();
181
		$data = $cursor->fetch();
182
		if ($data === false) {
183
			throw new MemberDoesNotExistException($this->l10n->t('This member does not exist'));
184
		}
185
186
		$group = $this->parseGroupsSelectSql($data);
187
		$cursor->closeCursor();
188
189
		return $group;
190
	}
191
192
193
	/**

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-223 (lines=16) @@
205
	 * @return FederatedLink
206
	 * @throws FederatedLinkDoesNotExistException
207
	 */
208
	public function getLinkFromId($linkUniqueId) {
209
		$qb = $this->getLinksSelectSql();
210
		$this->limitToShortenUniqueId($qb, $linkUniqueId, FederatedLink::SHORT_UNIQUE_ID_LENGTH);
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
		$entry = $this->parseLinksSelectSql($data);
221
222
		return $entry;
223
	}
224
225
226
}

lib/Db/SharingFrameRequest.php 1 location

@@ 50-69 (lines=20) @@
47
	 * @return SharingFrame
48
	 * @throws SharingFrameDoesNotExistException
49
	 */
50
	public function getSharingFrame($circleUniqueId, $frameUniqueId) {
51
		$qb = $this->getSharesSelectSql();
52
		$this->limitToUniqueId($qb, $frameUniqueId);
53
		$this->limitToCircleId($qb, $circleUniqueId);
54
		$this->leftJoinCircle($qb);
55
56
		$cursor = $qb->execute();
57
		$data = $cursor->fetch();
58
		$cursor->closeCursor();
59
60
		if ($data === false) {
61
			throw new SharingFrameDoesNotExistException($this->l10n->t('Sharing Frame does not exist'));
62
		}
63
64
		$entry = $this->parseSharesSelectSql($data);
65
66
		return $entry;
67
	}
68
69
70
	/**
71
	 * @param string $circleUniqueId
72
	 *

lib/Db/CirclesRequest.php 1 location

@@ 337-352 (lines=16) @@
334
	 * @return Circle
335
	 * @throws CircleDoesNotExistException
336
	 */
337
	public function getCircleFromUniqueId($uniqueId) {
338
		$qb = $this->getCirclesSelectSql();
339
		$this->limitToUniqueId($qb, (string)$uniqueId);
340
341
		$cursor = $qb->execute();
342
		$data = $cursor->fetch();
343
		$cursor->closeCursor();
344
345
		if ($data === false) {
346
			throw new CircleDoesNotExistException($this->l10n->t('Circle not found'));
347
		}
348
349
		$entry = $this->parseCirclesSelectSql($data);
350
351
		return $entry;
352
	}
353
354
355
}