Issues (40)

lib/Utility/AppInfo.php (1 issue)

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 - 2025
11
 */
12
13
namespace OCA\Music\Utility;
14
15
class AppInfo {
16
17
	public const APP_ID = 'music';
18
19
	public static function getVersion() : string {
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
0 ignored issues
show
Deprecated Code introduced by
The function OCP\App::getAppVersion() has been deprecated: 14.0.0 use \OC::$server->getAppManager()->getAppVersion($appId) ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

26
			return /** @scrutinizer ignore-deprecated */ \OCP\App::getAppVersion(self::APP_ID); // OC or NC13

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
27
		}
28
	}
29
30
	public static function getVendor() : string {
31
		$vendor = 'owncloud/nextcloud'; // this should get overridden by the next 'include'
32
		include \OC::$SERVERROOT . '/version.php';
33
		return $vendor;
34
	}
35
36
	public static function getFullName() : string {
37
		return self::getVendor() . ' ' . self::APP_ID;
38
	}
39
}