Code Duplication    Length = 74-76 lines in 2 locations

lib/Db/GSEventsRequestBuilder.php 1 location

@@ 43-118 (lines=76) @@
40
 *
41
 * @package OCA\Circles\Db
42
 */
43
class GSEventsRequestBuilder extends CoreRequestBuilder {
44
45
46
	/**
47
	 * Base of the Sql Insert request for Shares
48
	 *
49
	 * @return IQueryBuilder
50
	 */
51
	protected function getGSEventsInsertSql() {
52
		$qb = $this->dbConnection->getQueryBuilder();
53
		$qb->insert(self::TABLE_GSEVENTS);
54
55
		return $qb;
56
	}
57
58
59
	/**
60
	 * Base of the Sql Update request for Groups
61
	 *
62
	 * @param int $circleId
63
	 * @param string $groupId
64
	 *
65
	 * @return IQueryBuilder
66
	 */
67
	protected function getGSEventsUpdateSql($circleId, $groupId) {
68
		$qb = $this->dbConnection->getQueryBuilder();
69
		$qb->update(self::TABLE_GSEVENTS);
70
71
		return $qb;
72
	}
73
74
75
	/**
76
	 * @return IQueryBuilder
77
	 */
78
	protected function getGSEventsSelectSql() {
79
		$qb = $this->dbConnection->getQueryBuilder();
80
81
		/** @noinspection PhpMethodParametersCountMismatchInspection */
82
		$qb->select('gs.token', 'gs.event', 'gs.creation')
83
		   ->from(self::TABLE_GSEVENTS, 'gs');
84
85
		$this->default_select_alias = 'gs';
86
87
		return $qb;
88
	}
89
90
91
	/**
92
	 * Base of the Sql Delete request
93
	 *
94
	 * @return IQueryBuilder
95
	 */
96
	protected function getGSEventsDeleteSql() {
97
		$qb = $this->dbConnection->getQueryBuilder();
98
		$qb->delete(self::TABLE_GSEVENTS);
99
100
		return $qb;
101
	}
102
103
104
	/**
105
	 * @param array $data
106
	 *
107
	 * @return GSWrapper
108
	 * @throws JsonException
109
	 * @throws ModelException
110
	 */
111
	protected function parseGSEventsSelectSql($data): GSWrapper {
112
		$wrapper = new GSWrapper();
113
		$wrapper->import($data);
114
115
		return $wrapper;
116
	}
117
118
}
119

lib/Db/TokensRequestBuilder.php 1 location

@@ 41-114 (lines=74) @@
38
 *
39
 * @package OCA\Circles\Db
40
 */
41
class TokensRequestBuilder extends CoreRequestBuilder {
42
43
44
	/**
45
	 * Base of the Sql Insert request for Shares
46
	 *
47
	 * @return IQueryBuilder
48
	 */
49
	protected function getTokensInsertSql() {
50
		$qb = $this->dbConnection->getQueryBuilder();
51
		$qb->insert(self::TABLE_TOKENS);
52
53
		return $qb;
54
	}
55
56
57
	/**
58
	 * Base of the Sql Update request for Groups
59
	 *
60
	 * @param int $circleId
61
	 * @param string $groupId
62
	 *
63
	 * @return IQueryBuilder
64
	 */
65
	protected function getTokensUpdateSql($circleId, $groupId) {
66
		$qb = $this->dbConnection->getQueryBuilder();
67
		$qb->update(self::TABLE_TOKENS);
68
69
		return $qb;
70
	}
71
72
73
	/**
74
	 * @return IQueryBuilder
75
	 */
76
	protected function getTokensSelectSql() {
77
		$qb = $this->dbConnection->getQueryBuilder();
78
79
		/** @noinspection PhpMethodParametersCountMismatchInspection */
80
		$qb->select('t.user_id', 't.circle_id', 't.share_id', 't.token')
81
		   ->from(self::TABLE_TOKENS, 't');
82
83
		$this->default_select_alias = 't';
84
85
		return $qb;
86
	}
87
88
89
	/**
90
	 * Base of the Sql Delete request
91
	 *
92
	 * @return IQueryBuilder
93
	 */
94
	protected function getTokensDeleteSql() {
95
		$qb = $this->dbConnection->getQueryBuilder();
96
		$qb->delete(self::TABLE_TOKENS);
97
98
		return $qb;
99
	}
100
101
102
	/**
103
	 * @param array $data
104
	 *
105
	 * @return SharesToken
106
	 */
107
	protected function parseTokensSelectSql($data) {
108
		$sharesToken = new SharesToken();
109
		$sharesToken->import($data);
110
111
		return $sharesToken;
112
	}
113
114
}
115