Code Duplication    Length = 23-23 lines in 2 locations

apps/sharebymail/lib/ShareByMailProvider.php 1 location

@@ 855-877 (lines=23) @@
852
	 * @return IShare
853
	 * @throws ShareNotFound
854
	 */
855
	public function getShareByToken($token) {
856
		$qb = $this->dbConnection->getQueryBuilder();
857
858
		$cursor = $qb->select('*')
859
			->from('share')
860
			->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL)))
861
			->andWhere($qb->expr()->eq('token', $qb->createNamedParameter($token)))
862
			->execute();
863
864
		$data = $cursor->fetch();
865
866
		if ($data === false) {
867
			throw new ShareNotFound('Share not found', $this->l->t('Could not find share'));
868
		}
869
870
		try {
871
			$share = $this->createShareObject($data);
872
		} catch (InvalidShare $e) {
873
			throw new ShareNotFound('Share not found', $this->l->t('Could not find share'));
874
		}
875
876
		return $share;
877
	}
878
879
	/**
880
	 * remove share from table

apps/federatedfilesharing/lib/FederatedShareProvider.php 1 location

@@ 815-837 (lines=23) @@
812
	 * @return IShare
813
	 * @throws ShareNotFound
814
	 */
815
	public function getShareByToken($token) {
816
		$qb = $this->dbConnection->getQueryBuilder();
817
818
		$cursor = $qb->select('*')
819
			->from('share')
820
			->where($qb->expr()->in('share_type', $qb->createNamedParameter($this->supportedShareType, IQueryBuilder::PARAM_INT_ARRAY)))
821
			->andWhere($qb->expr()->eq('token', $qb->createNamedParameter($token)))
822
			->execute();
823
824
		$data = $cursor->fetch();
825
826
		if ($data === false) {
827
			throw new ShareNotFound('Share not found', $this->l->t('Could not find share'));
828
		}
829
830
		try {
831
			$share = $this->createShareObject($data);
832
		} catch (InvalidShare $e) {
833
			throw new ShareNotFound('Share not found', $this->l->t('Could not find share'));
834
		}
835
836
		return $share;
837
	}
838
839
	/**
840
	 * get database row of a give share