Completed
Pull Request — master (#362)
by Maxence
01:49
created

GSEventsRequestBuilder::parseGSEventsSelectSql()   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 1
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\Exceptions\JsonException;
33
use OCA\Circles\Exceptions\ModelException;
34
use OCA\Circles\Model\GlobalScale\GSWrapper;
35
use OCP\DB\QueryBuilder\IQueryBuilder;
36
37
38
/**
39
 * Class GSEventsRequestBuilder
40
 *
41
 * @package OCA\Circles\Db
42
 */
43 View Code Duplication
class GSEventsRequestBuilder 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...
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
	 * @return IQueryBuilder
63
	 */
64
	protected function getGSEventsUpdateSql() {
65
		$qb = $this->dbConnection->getQueryBuilder();
66
		$qb->update(self::TABLE_GSEVENTS);
67
68
		return $qb;
69
	}
70
71
72
	/**
73
	 * @return IQueryBuilder
74
	 */
75
	protected function getGSEventsSelectSql() {
76
		$qb = $this->dbConnection->getQueryBuilder();
77
78
		/** @noinspection PhpMethodParametersCountMismatchInspection */
79
		$qb->select('gse.token', 'gse.event', 'gse.instance', 'gse.severity', 'gse.status', 'gse.creation')
80
		   ->from(self::TABLE_GSEVENTS, 'gse');
81
82
		$this->default_select_alias = 'gse';
83
84
		return $qb;
85
	}
86
87
88
	/**
89
	 * Base of the Sql Delete request
90
	 *
91
	 * @return IQueryBuilder
92
	 */
93
	protected function getGSEventsDeleteSql() {
94
		$qb = $this->dbConnection->getQueryBuilder();
95
		$qb->delete(self::TABLE_GSEVENTS);
96
97
		return $qb;
98
	}
99
100
101
	/**
102
	 * @param array $data
103
	 *
104
	 * @return GSWrapper
105
	 * @throws JsonException
106
	 * @throws ModelException
107
	 */
108
	protected function parseGSEventsSelectSql($data): GSWrapper {
109
		$wrapper = new GSWrapper();
110
		$wrapper->import($data);
111
112
		return $wrapper;
113
	}
114
115
}
116