Completed
Push — master ( 65e3b0...b26a8a )
by
unknown
31:46 queued 19:29
created

JobStatusMapper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A findByUserIdAndJobId() 0 8 1
1
<?php
2
/**
3
 * @author Thomas Müller <[email protected]>
4
 *
5
 * @copyright Copyright (c) 2018, ownCloud GmbH
6
 * @license AGPL-3.0
7
 *
8
 * This code is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU Affero General Public License, version 3,
10
 * as published by the Free Software Foundation.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
 * GNU Affero General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Affero General Public License, version 3,
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
19
 *
20
 */
21
22
namespace OCA\DAV\JobStatus\Entity;
23
24
use OCP\AppFramework\Db\Mapper;
25
use OCP\IDBConnection;
26
27
class JobStatusMapper extends Mapper {
28
	public function __construct(IDBConnection $db) {
29
		parent::__construct($db, 'dav_job_status');
30
	}
31
32
	/**
33
	 * @param string $userId
34
	 * @param string $jobId
35
	 * @return JobStatus
36
	 * @throws \OCP\AppFramework\Db\DoesNotExistException
37
	 * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
38
	 */
39
	public function findByUserIdAndJobId($userId, $jobId) {
40
		$query = $this->db->getQueryBuilder();
41
		$query->select('*')
42
			->from($this->getTableName())
43
			->where($query->expr()->eq('uuid', $query->createNamedParameter($jobId)))
44
			->andWhere($query->expr()->eq('user_id', $query->createNamedParameter($userId)));
45
		return $this->mapRowToEntity($this->findOneQuery($query->getSQL(), $query->getParameters()));
46
	}
47
}
48