Completed
Push — master ( 4bb4df...375c4e )
by Sander
10s
created

DeleteVaultRequestMapper   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 45
ccs 0
cts 13
cp 0
rs 10
c 1
b 0
f 0
wmc 5
lcom 0
cbo 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A createRequest() 0 3 1
A getDeleteRequests() 0 4 1
A getDeleteRequestsForVault() 0 4 1
A removeDeleteVaultRequest() 0 3 1
1
<?php
2
/**
3
 * Nextcloud - passman
4
 *
5
 * @copyright Copyright (c) 2016, Sander Brand ([email protected])
6
 * @copyright Copyright (c) 2016, Marcos Zuriaga Miguel ([email protected])
7
 * @license GNU AGPL version 3 or any later version
8
 *
9
 * This program is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU Affero General Public License as
11
 * published by the Free Software Foundation, either version 3 of the
12
 * License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU Affero General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Affero General Public License
20
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 *
22
 */
23
24
namespace OCA\Passman\Db;
25
26
27
use Icewind\SMB\Share;
28
use OCA\Passman\Utility\Utils;
29
use OCP\AppFramework\Db\DoesNotExistException;
30
use OCP\AppFramework\Db\Mapper;
31
use OCP\IDBConnection;
32
33
class DeleteVaultRequestMapper extends Mapper {
34
	const TABLE_NAME = 'passman_delete_vault_request';
35
36
	public function __construct(IDBConnection $db) {
37
		parent::__construct($db, self::TABLE_NAME);
38
	}
39
40
	/**
41
	 * Create a new enty in the db
42
	 * @param DeleteVaultRequest $request
43
	 * @return \OCP\AppFramework\Db\Entity
44
	 */
45
	public function createRequest(DeleteVaultRequest $request){
46
		return $this->insert($request);
47
	}
48
49
	/**
50
	 * Get all delete requests
51
	 * @return \OCP\AppFramework\Db\Entity
52
	 */
53
	public function getDeleteRequests(){
54
		$q = "SELECT * FROM *PREFIX*" . self::TABLE_NAME;
55
		return $this->findEntities($q);
56
	}
57
58
	/**
59
	 * Get request for an vault id
60
	 * @param $vault_id integer The vault id
61
	 * @return \OCP\AppFramework\Db\Entity
62
	 */
63
	public function getDeleteRequestsForVault($vault_guid){
64
		$q = "SELECT * FROM *PREFIX*" . self::TABLE_NAME .' WHERE `vault_guid` = ?';
65
		return $this->findEntity($q, [$vault_guid]);
66
	}
67
68
	/**
69
	 * Deletes the given delete request
70
	 * @param DeleteVaultRequest $request    Request to delete
71
	 * @return DeleteVaultRequest                 The deleted request
72
	 */
73
	public function removeDeleteVaultRequest(DeleteVaultRequest $request){
74
		return $this->delete($request);
75
	}
76
77
}