Code Duplication    Length = 16-17 lines in 3 locations

apps/dav/lib/CardDAV/CardDavBackend.php 1 location

@@ 1077-1092 (lines=16) @@
1074
	 * @param string $uri
1075
	 * @return int
1076
	 */
1077
	protected function getCardId($addressBookId, $uri) {
1078
		$query = $this->db->getQueryBuilder();
1079
		$query->select('id')->from($this->dbCardsTable)
1080
			->where($query->expr()->eq('uri', $query->createNamedParameter($uri)))
1081
			->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)));
1082
1083
		$result = $query->execute();
1084
		$cardIds = $result->fetch();
1085
		$result->closeCursor();
1086
1087
		if (!isset($cardIds['id'])) {
1088
			throw new \InvalidArgumentException('Card does not exists: ' . $uri);
1089
		}
1090
1091
		return (int)$cardIds['id'];
1092
	}
1093
1094
	/**
1095
	 * For shared address books the sharee is set in the ACL of the address book

apps/federation/lib/DbHandler.php 1 location

@@ 193-209 (lines=17) @@
190
	 * @return string
191
	 * @throws \Exception
192
	 */
193
	public function getToken($url) {
194
		$hash = $this->hash($url);
195
		$query = $this->connection->getQueryBuilder();
196
		$query->select('token')->from($this->dbTable)
197
			->where($query->expr()->eq('url_hash', $query->createParameter('url_hash')))
198
			->setParameter('url_hash', $hash);
199
200
		$statement = $query->execute();
201
		$result = $statement->fetch();
202
		$statement->closeCursor();
203
204
		if (!isset($result['token'])) {
205
			throw new \Exception('No token found for: ' . $url);
206
		}
207
208
		return $result['token'];
209
	}
210
211
	/**
212
	 * add shared Secret to database

apps/dav/lib/CalDAV/CalDavBackend.php 1 location

@@ 2334-2349 (lines=16) @@
2331
	 * @param string $uri
2332
	 * @return int
2333
	 */
2334
	protected function getCalendarObjectId($calendarId, $uri) {
2335
		$query = $this->db->getQueryBuilder();
2336
		$query->select('id')->from('calendarobjects')
2337
			->where($query->expr()->eq('uri', $query->createNamedParameter($uri)))
2338
			->andWhere($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId)));
2339
2340
		$result = $query->execute();
2341
		$objectIds = $result->fetch();
2342
		$result->closeCursor();
2343
2344
		if (!isset($objectIds['id'])) {
2345
			throw new \InvalidArgumentException('Calendarobject does not exists: ' . $uri);
2346
		}
2347
2348
		return (int)$objectIds['id'];
2349
	}
2350
2351
	private function convertPrincipal($principalUri, $toV2) {
2352
		if ($this->principalBackend->getPrincipalPrefix() === 'principals') {