Passed
Push — master ( 49e88e...27428c )
by Pauli
02:49 queued 10s
created

RadioStationMapper::findUniqueEntity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
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 Pauli Järvinen <[email protected]>
10
 * @copyright Pauli Järvinen 2020
11
 */
12
13
namespace OCA\Music\Db;
14
15
use \OCP\AppFramework\Db\Entity;
16
use \OCP\IDBConnection;
17
18
/**
19
 * @method RadioStation findEntity(string $sql, array $params)
20
 */
21
class RadioStationMapper extends BaseMapper {
22
	public function __construct(IDBConnection $db) {
23
		parent::__construct($db, 'music_radio_stations', '\OCA\Music\Db\RadioStation', 'name');
24
	}
25
26
	/**
27
	 * @return RadioStation
28
	 */
29
	public function findByStreamUrl(string $url, string $userId) : RadioStation {
30
		$sql = $this->selectUserEntities("`stream_url` = ?");
31
		return $this->findEntity($sql, [$userId, $url]);
32
	}
33
34
	/**
35
	 * @see \OCA\Music\Db\BaseMapper::findUniqueEntity()
36
	 */
37
	protected function findUniqueEntity(Entity $station) : Entity {
38
		// The radio_stations table has no unique constraints, and hence, this function
39
		// should never be called.
40
		throw new \BadMethodCallException('not supported');
41
	}
42
}
43