Completed
Push — master ( 5a6198...a64e14 )
by Maxence
17s queued 10s
created

SharesRequestBuilder::getSharesDeleteSql()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 10
loc 10
rs 9.9332
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
namespace OCA\Circles\Db;
29
30
31
use OCP\DB\QueryBuilder\IQueryBuilder;
32
33
class SharesRequestBuilder extends CoreRequestBuilder {
34
35
36
	/**
37
	 * Base of the Sql Delete request
38
	 *
39
	 * @return IQueryBuilder
40
	 */
41 View Code Duplication
	protected function getSharesDeleteSql() {
0 ignored issues
show
Duplication introduced by
This method 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
		$qb = $this->dbConnection->getQueryBuilder();
43
		$qb->delete(self::TABLE_FILE_SHARES);
44
		$qb->where(
45
			$qb->expr()
46
			   ->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE))
47
		);
48
49
		return $qb;
50
	}
51
52
53
	/**
54
	 * @return IQueryBuilder
55
	 */
56
	protected function getSharesSelectSql() {
57
		$qb = $this->dbConnection->getQueryBuilder();
58
59
		/** @noinspection PhpMethodParametersCountMismatchInspection */
60
		$qb->select('s.id', 's.token')
61
		   ->from(self::TABLE_FILE_SHARES, 's');
62
63
		$this->defaultSelectAlias = 's';
0 ignored issues
show
Bug introduced by
The property defaultSelectAlias does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
64
65
		return $qb;
66
	}
67
68
69
	/**
70
	 * @return IQueryBuilder
71
	 */
72
	protected function getSharesUpdateSql() {
73
		$qb = $this->dbConnection->getQueryBuilder();
74
		$qb->update(self::TABLE_FILE_SHARES);
75
76
		return $qb;
77
	}
78
79
80
}
81