Passed
Push — master ( 45ff17...c44188 )
by Pauli
02:46
created

AppInfo::getVersion()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 8
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 2022
11
 */
12
13
namespace OCA\Music\Utility;
14
15
class AppInfo {
16
17
	public const APP_ID = 'music';
18
19
	public static function getVersion() {
20
		// Nextcloud 14 introduced a new API for this which is not available on ownCloud.
21
		// Nextcloud 25 removed the old API for good.
22
		$appManager = \OC::$server->getAppManager();
23
		if (\method_exists($appManager, 'getAppVersion')) {
24
			return $appManager->getAppVersion(self::APP_ID); // NC14+
25
		} else {
26
			return \OCP\App::getAppVersion(self::APP_ID); // OC or NC13
27
		}
28
	}
29
}