Code Duplication    Length = 14-19 lines in 7 locations

apps/dav/lib/Db/DirectMapper.php 1 location

@@ 42-60 (lines=19) @@
39
	 * @return Direct
40
	 * @throws DoesNotExistException
41
	 */
42
	public function getByToken(string $token): Direct {
43
		$qb = $this->db->getQueryBuilder();
44
45
		$qb->select('*')
46
			->from('directlink')
47
			->where(
48
				$qb->expr()->eq('token', $qb->createNamedParameter($token))
49
			);
50
51
		$cursor = $qb->execute();
52
		$data = $cursor->fetch();
53
		$cursor->closeCursor();
54
55
		if ($data === false) {
56
			throw new DoesNotExistException('Direct link with token does not exist');
57
		}
58
59
		return Direct::fromRow($data);
60
	}
61
62
	public function deleteExpired(int $expiration) {
63
		$qb = $this->db->getQueryBuilder();

apps/oauth2/lib/Db/AccessTokenMapper.php 1 location

@@ 43-56 (lines=14) @@
40
	 * @return AccessToken
41
	 * @throws AccessTokenNotFoundException
42
	 */
43
	public function getByCode($code) {
44
		$qb = $this->db->getQueryBuilder();
45
		$qb
46
			->select('*')
47
			->from($this->tableName)
48
			->where($qb->expr()->eq('hashed_code', $qb->createNamedParameter(hash('sha512', $code))));
49
		$result = $qb->execute();
50
		$row = $result->fetch();
51
		$result->closeCursor();
52
		if($row === false) {
53
			throw new AccessTokenNotFoundException();
54
		}
55
		return AccessToken::fromRow($row);
56
	}
57
58
	/**
59
	 * delete all access token from a given client

apps/oauth2/lib/Db/ClientMapper.php 2 locations

@@ 43-56 (lines=14) @@
40
	 * @return Client
41
	 * @throws ClientNotFoundException
42
	 */
43
	public function getByIdentifier($clientIdentifier) {
44
		$qb = $this->db->getQueryBuilder();
45
		$qb
46
			->select('*')
47
			->from($this->tableName)
48
			->where($qb->expr()->eq('client_identifier', $qb->createNamedParameter($clientIdentifier)));
49
		$result = $qb->execute();
50
		$row = $result->fetch();
51
		$result->closeCursor();
52
		if($row === false) {
53
			throw new ClientNotFoundException();
54
		}
55
		return Client::fromRow($row);
56
	}
57
58
	/**
59
	 * @param string $uid internal uid of the client
@@ 63-76 (lines=14) @@
60
	 * @return Client
61
	 * @throws ClientNotFoundException
62
	 */
63
	public function getByUid($uid) {
64
		$qb = $this->db->getQueryBuilder();
65
		$qb
66
			->select('*')
67
			->from($this->tableName)
68
			->where($qb->expr()->eq('id', $qb->createNamedParameter($uid, IQueryBuilder::PARAM_INT)));
69
		$result = $qb->execute();
70
		$row = $result->fetch();
71
		$result->closeCursor();
72
		if($row === false) {
73
			throw new ClientNotFoundException();
74
		}
75
		return Client::fromRow($row);
76
	}
77
78
	/**
79
	 * @return Client[]

apps/sharebymail/lib/ShareByMailProvider.php 1 location

@@ 1006-1023 (lines=18) @@
1003
	 * @return array
1004
	 * @throws ShareNotFound
1005
	 */
1006
	protected function getRawShare($id) {
1007
1008
		// Now fetch the inserted share and create a complete share object
1009
		$qb = $this->dbConnection->getQueryBuilder();
1010
		$qb->select('*')
1011
			->from('share')
1012
			->where($qb->expr()->eq('id', $qb->createNamedParameter($id)));
1013
1014
		$cursor = $qb->execute();
1015
		$data = $cursor->fetch();
1016
		$cursor->closeCursor();
1017
1018
		if ($data === false) {
1019
			throw new ShareNotFound;
1020
		}
1021
1022
		return $data;
1023
	}
1024
1025
	public function getSharesInFolder($userId, Folder $node, $reshares) {
1026
		$qb = $this->dbConnection->getQueryBuilder();

lib/private/Updater/ChangesMapper.php 1 location

@@ 42-56 (lines=15) @@
39
	/**
40
	 * @throws DoesNotExistException
41
	 */
42
	public function getChanges(string $version): ChangesResult {
43
		/* @var $qb IQueryBuilder */
44
		$qb = $this->db->getQueryBuilder();
45
		$result = $qb->select('*')
46
			->from(self::TABLE_NAME)
47
			->where($qb->expr()->eq('version', $qb->createNamedParameter($version)))
48
			->execute();
49
50
		$data = $result->fetch();
51
		$result->closeCursor();
52
		if ($data === false) {
53
			throw new DoesNotExistException('Changes info is not present');
54
		}
55
		return ChangesResult::fromRow($data);
56
	}
57
}
58

apps/federatedfilesharing/lib/FederatedShareProvider.php 1 location

@@ 821-838 (lines=18) @@
818
	 * @return array
819
	 * @throws ShareNotFound
820
	 */
821
	private function getRawShare($id) {
822
823
		// Now fetch the inserted share and create a complete share object
824
		$qb = $this->dbConnection->getQueryBuilder();
825
		$qb->select('*')
826
			->from('share')
827
			->where($qb->expr()->eq('id', $qb->createNamedParameter($id)));
828
829
		$cursor = $qb->execute();
830
		$data = $cursor->fetch();
831
		$cursor->closeCursor();
832
833
		if ($data === false) {
834
			throw new ShareNotFound;
835
		}
836
837
		return $data;
838
	}
839
840
	/**
841
	 * Create a share object from an database row