Completed
Pull Request — master (#1523)
by
unknown
08:12
created

AliasMapper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 7
Bugs 3 Features 2
Metric Value
wmc 3
c 7
b 3
f 2
lcom 0
cbo 0
dl 0
loc 34
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A find() 0 4 1
A findAll() 0 8 1
1
<?php
2
3
/**
4
 * ownCloud - Mail
5
 *
6
 * This file is licensed under the Affero General Public License version 3 or
7
 * later. See the COPYING file.
8
 *
9
 * @author Tahaa Karim <[email protected]>
10
 * @copyright Tahaa Karim 2016
11
 */
12
13
namespace OCA\Mail\Db;
14
15
use OCP\AppFramework\Db\Mapper;
16
use OCP\IDb;
17
18
class AliasMapper extends Mapper {
19
20
	/**
21
	 * @param IDb $db
22
	 */
23
	public function __construct(IDb $db) {
24
		parent::__construct($db, 'mail_aliases');
25
	}
26
27
	/**
28
	 * @param int $accountId
29
	 * @param int $aliasId
30
	 * @param string $currentUserId
31
	 * @return Alias[]
32
	 */
33
	public function find($accountId, $aliasId, $currentUserId) {
34
		$sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE id = ? AND user_id = ? AND account_id = ?';
35
		return $this->findEntity($sql, [$aliasId, $currentUserId, $accountId]);
36
	}
37
38
	/**
39
	 * @param int $accountId
40
	 * @param string $currentUserId
41
	 * @return Alias
42
	 */
43
	public function findAll($accountId, $currentUserId) {
44
		$sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE `account_id` = ? AND `user_id` = ?';
45
		$params = [
46
			$accountId,
47
			$currentUserId
48
		];
49
		return $this->findEntities($sql, $params);
50
	}
51
}
52