Passed
Push — master ( c99a0d...8fdbaf )
by Pauli
03:18
created

RadioStationMapper::advFormatSqlCondition()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 3
dl 0
loc 6
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 Pauli Järvinen <[email protected]>
10
 * @copyright Pauli Järvinen 2020 - 2025
11
 */
12
13
namespace OCA\Music\Db;
14
15
use OCP\IConfig;
16
use OCP\IDBConnection;
17
18
/**
19
 * @method RadioStation findEntity(string $sql, array $params)
20
 * @phpstan-extends BaseMapper<RadioStation>
21
 */
22
class RadioStationMapper extends BaseMapper {
23
	public function __construct(IDBConnection $db, IConfig $config) {
24
		parent::__construct($db, $config, 'music_radio_stations', RadioStation::class, 'name');
25
	}
26
27
	/**
28
	 * @return RadioStation
29
	 */
30
	public function findByStreamUrl(string $url, string $userId) : RadioStation {
31
		$sql = $this->selectUserEntities("`stream_url` = ?");
32
		return $this->findEntity($sql, [$userId, $url]);
33
	}
34
35
	/**
36
	 * Overridden from the base implementation to provide support for table-specific rules
37
	 *
38
	 * {@inheritdoc}
39
	 * @see BaseMapper::advFormatSqlCondition()
40
	 */
41
	protected function advFormatSqlCondition(string $rule, string $sqlOp, string $conv) : string {
42
		$condForRule = [
43
			'stream_url' => "$conv(`stream_url`) $sqlOp $conv(?)",
44
		];
45
46
		return $condForRule[$rule] ?? parent::advFormatSqlCondition($rule, $sqlOp, $conv);
47
	}
48
}
49