Test Failed
Push — master ( dc798f...d76e2d )
by Daniel
48:22
created

WebsitesRequestBuilder::getWebsitesInsertSql()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 5
c 2
b 0
f 0
dl 0
loc 8
ccs 0
cts 5
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * CMS Pico - Create websites using Pico CMS for Nextcloud.
4
 *
5
 * @copyright Copyright (c) 2017, Maxence Lange (<[email protected]>)
6
 * @copyright Copyright (c) 2019, Daniel Rudolf (<[email protected]>)
7
 *
8
 * @license GNU AGPL version 3 or any later version
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU Affero General Public License as
12
 * published by the Free Software Foundation, either version 3 of the
13
 * License, or (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU Affero General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU Affero General Public License
21
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
 */
23
24
declare(strict_types=1);
25
26
namespace OCA\CMSPico\Db;
27
28
use OCA\CMSPico\Model\Website;
29
use OCP\DB\QueryBuilder\IQueryBuilder;
30
31
class WebsitesRequestBuilder extends CoreRequestBuilder
32
{
33
	/**
34
	 * @return IQueryBuilder
35
	 */
36
	protected function getWebsitesInsertSql(): IQueryBuilder
37
	{
38
		$qb = $this->dbConnection->getQueryBuilder();
39
		$qb
40
			->insert(self::TABLE_WEBSITES)
41
			->setValue('creation', $qb->createFunction('NOW()'));
42
43
		return $qb;
44
	}
45
46
	/**
47
	 * @return IQueryBuilder
48
	 */
49
	protected function getWebsitesUpdateSql(): IQueryBuilder
50
	{
51
		return $this->dbConnection->getQueryBuilder()
52
			->update(self::TABLE_WEBSITES);
53
	}
54
55
	/**
56
	 * @return IQueryBuilder
57
	 */
58 10
	protected function getWebsitesSelectSql(): IQueryBuilder
59
	{
60 10
		return $this->dbConnection->getQueryBuilder()
61 10
			->select('id', 'name', 'user_id', 'site', 'theme', 'type', 'options', 'path', 'creation')
62 10
			->from(self::TABLE_WEBSITES);
63
	}
64
65
	/**
66
	 * @return IQueryBuilder
67
	 */
68
	protected function getWebsitesDeleteSql(): IQueryBuilder
69
	{
70
		return $this->dbConnection->getQueryBuilder()
71
			->delete(self::TABLE_WEBSITES);
72
	}
73
74
	/**
75
	 * @param array $data
76
	 *
77
	 * @return Website
78
	 */
79
	protected function parseWebsitesSelectSql(array $data): Website
80
	{
81
		return new Website($data);
82
	}
83
}
84