Completed
Pull Request — master (#362)
by Maxence
02:13
created

GSSharesRequestBuilder::getGSSharesInsertSql()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
dl 6
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * Circles - Bring cloud-users closer together.
5
 *
6
 * This file is licensed under the Affero General Public License version 3 or
7
 * later. See the COPYING file.
8
 *
9
 * @author Maxence Lange <[email protected]>
10
 * @copyright 2017
11
 * @license GNU AGPL version 3 or any later version
12
 *
13
 * This program is free software: you can redistribute it and/or modify
14
 * it under the terms of the GNU Affero General Public License as
15
 * published by the Free Software Foundation, either version 3 of the
16
 * License, or (at your option) any later version.
17
 *
18
 * This program is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 * GNU Affero General Public License for more details.
22
 *
23
 * You should have received a copy of the GNU Affero General Public License
24
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
25
 *
26
 */
27
28
29
namespace OCA\Circles\Db;
30
31
32
use OCA\Circles\Model\GlobalScale\GSShare;
33
use OCP\DB\QueryBuilder\IQueryBuilder;
34
35
36
/**
37
 * Class GSSharesRequestBuilder
38
 *
39
 * @package OCA\Circles\Db
40
 */
41 View Code Duplication
class GSSharesRequestBuilder extends CoreRequestBuilder {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
42
43
44
	/**
45
	 * Base of the Sql Insert request for Shares
46
	 *
47
	 * @return IQueryBuilder
48
	 */
49
	protected function getGSSharesInsertSql() {
50
		$qb = $this->dbConnection->getQueryBuilder();
51
		$qb->insert(self::TABLE_GSSHARES);
52
53
		return $qb;
54
	}
55
56
57
	/**
58
	 * Base of the Sql Update request for Groups
59
	 *
60
	 * @return IQueryBuilder
61
	 */
62
	protected function getGSSharesUpdateSql() {
63
		$qb = $this->dbConnection->getQueryBuilder();
64
		$qb->update(self::TABLE_GSSHARES);
65
66
		return $qb;
67
	}
68
69
70
	/**
71
	 * @return IQueryBuilder
72
	 */
73
	protected function getGSSharesSelectSql() {
74
		$qb = $this->dbConnection->getQueryBuilder();
75
76
		/** @noinspection PhpMethodParametersCountMismatchInspection */
77
		$qb->select(
78
			'gsh.id', 'gsh.circle_unique_id', 'gsh.owner', 'gsh.instance', 'gsh.token', 'gsh.parent',
79
			'gsh.mountpoint', 'gsh.mountpoint_hash'
80
		)
81
		   ->from(self::TABLE_GSSHARES, 'gsh');
82
83
		$this->default_select_alias = 'gsh';
84
85
		return $qb;
86
	}
87
88
89
	/**
90
	 * Base of the Sql Delete request
91
	 *
92
	 * @return IQueryBuilder
93
	 */
94
	protected function getGSSharesDeleteSql() {
95
		$qb = $this->dbConnection->getQueryBuilder();
96
		$qb->delete(self::TABLE_GSSHARES);
97
98
		return $qb;
99
	}
100
101
102
	/**
103
	 * @param array $data
104
	 *
105
	 * @return GSShare
106
	 */
107
	protected function parseGSSharesSelectSql($data): GSShare {
108
		$share = new GSShare();
109
		$share->importFromDatabase($data);
110
111
		return $share;
112
	}
113
114
}
115