Code Duplication    Length = 23-24 lines in 2 locations

apps/federatedfilesharing/lib/federatedshareprovider.php 2 locations

@@ 353-376 (lines=24) @@
350
	/**
351
	 * @inheritdoc
352
	 */
353
	public function getShareById($id, $recipientId = null) {
354
		$qb = $this->dbConnection->getQueryBuilder();
355
356
		$qb->select('*')
357
			->from('share')
358
			->where($qb->expr()->eq('id', $qb->createNamedParameter($id)))
359
			->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_REMOTE)));
360
		
361
		$cursor = $qb->execute();
362
		$data = $cursor->fetch();
363
		$cursor->closeCursor();
364
365
		if ($data === false) {
366
			throw new ShareNotFound();
367
		}
368
369
		try {
370
			$share = $this->createShare($data);
371
		} catch (InvalidShare $e) {
372
			throw new ShareNotFound();
373
		}
374
375
		return $share;
376
	}
377
378
	/**
379
	 * Get shares for a given path
@@ 449-471 (lines=23) @@
446
	 * @return IShare
447
	 * @throws ShareNotFound
448
	 */
449
	public function getShareByToken($token) {
450
		$qb = $this->dbConnection->getQueryBuilder();
451
452
		$cursor = $qb->select('*')
453
			->from('share')
454
			->where($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_REMOTE)))
455
			->andWhere($qb->expr()->eq('token', $qb->createNamedParameter($token)))
456
			->execute();
457
458
		$data = $cursor->fetch();
459
460
		if ($data === false) {
461
			throw new ShareNotFound();
462
		}
463
464
		try {
465
			$share = $this->createShare($data);
466
		} catch (InvalidShare $e) {
467
			throw new ShareNotFound();
468
		}
469
470
		return $share;
471
	}
472
473
	/**
474
	 * get database row of a give share