Passed
Push — master ( d93244...31d6f2 )
by Pauli
03:37
created

BookmarkMapper::findUniqueEntity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
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 - 2025
13
 */
14
15
namespace OCA\Music\Db;
16
17
use OCP\IConfig;
18
use OCP\IDBConnection;
19
20
/**
21
 * Type hint a base class method to help Scrutinizer
22
 * @method Bookmark findEntity(string $sql, array $params=[], ?int $limit=null, ?int $offset=null)
23
 * @phpstan-extends BaseMapper<Bookmark>
24
 */
25
class BookmarkMapper extends BaseMapper {
26
	public function __construct(IDBConnection $db, IConfig $config) {
27
		parent::__construct($db, $config, 'music_bookmarks', Bookmark::class, 'comment', ['type', 'entry_id', 'user_id']);
28
	}
29
30
	public function findByEntry(int $type, int $entryId, string $userId) : Bookmark {
31
		$sql = $this->selectUserEntities("`type` = ? AND `entry_id` = ?");
32
		return $this->findEntity($sql, [$userId, $type, $entryId]);
33
	}
34
}
35