Completed
Pull Request — master (#1523)
by
unknown
09:17
created

AliasMapper::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 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
use OCP\IUserSession;
18
19
class AliasMapper extends Mapper {
20
21
	/**
22
	 * @param IDb $db
23
	 */
24
	public function __construct(IDb $db) {
25
		parent::__construct($db, 'mail_aliases');
26
	}
27
28
	/**
29
	 * @param int $id
30
	 * @param string $currentUserId
31
	 * @return Alias[]
32
	 */
33
	public function find($id, $currentUserId) {
34
		$sql = 'SELECT * FROM ' . $this->getTableName() . ' WHERE id = ? AND user_id = ?';
35
		return $this->findEntity($sql, [$id, $currentUserId]);
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
		return $this->findEntities($sql, [$accountId, $currentUserId]);
46
	}
47
}
48