ApiKeyMapper::findByUser()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 5
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 5
loc 5
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
namespace OCA\Maps\Db;
3
4
use OCP\AppFramework\Db\Mapper;
5
use OCP\IDb;
6
7 View Code Duplication
class ApiKeyMapper extends Mapper {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
9 1
	public function __construct(IDB $db) {
10 1
		parent::__construct($db, 'maps_apikeys', '\OCA\Maps\Db\ApiKey');
11 1
	}
12
13
	/**
14
	 * @param int $id
15
	 * @throws \OCP\AppFramework\Db\DoesNotExistException if not found
16
	 * @return ApiKey
17
	 */
18
	public function find($id) {
19
		$sql = 'SELECT * FROM `*PREFIX*maps_apikeys` '.
20
			'WHERE `id` = ?';
21
		return $this->findEntity($sql, [$id]);
22
	}
23
24
	/**
25
	 * @param string $uid
26
	 * @throws \OCP\AppFramework\Db\DoesNotExistException if not found
27
	 * @return ApiKey
28
	 */
29 1
	public function findByUser($uid) {
30
		$sql = 'SELECT * FROM `*PREFIX*maps_apikeys` '.
31 1
			'WHERE `user_id` = ?';
32 1
		return $this->findEntity($sql, [$uid]);
33
	}
34
35
	/**
36
	 * @param int $limit
37
	 * @param int $offset
38
	 * @return ApiKey[]
39
	 */
40
	public function findAll($limit=null, $offset=null) {
41
		$sql = 'SELECT * FROM `*PREFIX*maps_apikeys`';
42
		return $this->findEntities($sql, $limit, $offset);
43
	}
44
}
45