LocationMapper   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 43
ccs 0
cts 18
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A find() 0 5 1
A findBetween() 0 6 1
A findAll() 0 4 1
1
<?php
2
namespace OCA\Maps\Db;
3
4
use OCP\AppFramework\Db\Mapper;
5
use OCP\IDb;
6
7
class LocationMapper extends Mapper {
8
9
	public function __construct(IDB $db) {
10
		parent::__construct($db, 'maps_locations', '\OCA\Maps\Db\Location');
11
	}
12
13
	/**
14
	 * @param int $id
15
	 * @throws \OCP\AppFramework\Db\DoesNotExistException if not found
16
	 * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
17
	 * @return Location
18
	 */
19
	public function find($id) {
20
		$sql = 'SELECT * FROM `*PREFIX*maps_locations` '.
21
			'WHERE `id` = ?';
22
		return $this->findEntity($sql, [$id]);
23
	}
24
25
	/**
26
	 * @param string $deviceHash
27
	 * @param string $from
28
	 * @param string $until
29
	 * @param int $limit
30
	 * @param int $offset
31
	 * @return Location[]
32
	 */
33
	public function findBetween($deviceHash, $from, $until, $limit=null, $offset=null) {
34
		$sql = 'SELECT * FROM `*PREFIX*maps_locations` '.
35
			'WHERE `device_hash` = ?'.
36
			'AND `timestamp` BETWEEN ? and ?';
37
		return $this->findEntities($sql, [$deviceHash, $from, $until], $limit, $offset);
38
	}
39
40
	/**
41
	 * @param int $limit
42
	 * @param int $offset
43
	 * @return Location[]
44
	 */
45
	public function findAll($limit=null, $offset=null) {
46
		$sql = 'SELECT * FROM `*PREFIX*maps_locations`';
47
		return $this->findEntities($sql, $limit, $offset);
48
	}
49
}
50