Completed
Push — master ( 5cb984...bfe119 )
by
unknown
07:11
created

ApiKeyMapper::find()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 5
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 5
loc 5
rs 9.4285
cc 1
eloc 4
nc 1
nop 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
	public function __construct(IDB $db) {
10
		parent::__construct($db, 'maps_apikeys', '\OCA\Maps\Db\ApiKey');
11
	}
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
	public function findByUser($uid) {
30
		$sql = 'SELECT * FROM `*PREFIX*maps_apikeys` '.
31
			'WHERE `user_id` = ?';
32
		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