Passed
Push — master ( 0837cd...cb2cf5 )
by Pauli
02:00
created

BookmarkMapper::findByTrack()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
/**
4
 * ownCloud - Music app
5
 *
6
 * This file is licensed under the Affero General Public License version 3 or
7
 * later. See the COPYING file.
8
 *
9
 * @author Gavin E <[email protected]>
10
 * @author Pauli Järvinen <[email protected]>
11
 * @copyright Gavin E 2020
12
 * @copyright Pauli Järvinen 2020
13
 */
14
15
namespace OCA\Music\Db;
16
17
use OCP\IDBConnection;
0 ignored issues
show
Bug introduced by
The type OCP\IDBConnection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
19
class BookmarkMapper extends BaseMapper {
20
	public function __construct(IDBConnection $db) {
21
		parent::__construct($db, 'music_bookmarks', '\OCA\Music\Db\Bookmark', 'comment');
22
	}
23
24
	/**
25
	 * @param int $trackId
26
	 * @param string $userId
27
	 * @return Bookmark
28
	 */
29
	public function findByTrack($trackId, $userId) {
30
		$sql = $this->selectUserEntities("`track_id` = ?");
31
		return $this->findEntity($sql, [$userId, $trackId]);
32
	}
33
34
	/**
35
	 * @see \OCA\Music\Db\BaseMapper::findUniqueEntity()
36
	 * @param Bookmark $bookmark
37
	 * @return Bookmark
38
	 */
39
	protected function findUniqueEntity($bookmark) {
40
		return $this->findByTrack($bookmark->getTrackId(), $bookmark->getUserId());
41
	}
42
}
43