Application   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Test Coverage

Coverage 23.08%

Importance

Changes 6
Bugs 0 Features 0
Metric Value
wmc 8
eloc 24
c 6
b 0
f 0
dl 0
loc 71
ccs 6
cts 26
cp 0.2308
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A registerEventListener() 0 10 1
A getAppWebPath() 0 7 2
A getAppVersion() 0 7 2
A __construct() 0 3 1
A getAppPath() 0 7 2
1
<?php
2
/**
3
 * CMS Pico - Create websites using Pico CMS for Nextcloud.
4
 *
5
 * @copyright Copyright (c) 2017, Maxence Lange (<[email protected]>)
6
 * @copyright Copyright (c) 2019, Daniel Rudolf (<[email protected]>)
7
 *
8
 * @license GNU AGPL version 3 or any later version
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU Affero General Public License as
12
 * published by the Free Software Foundation, either version 3 of the
13
 * License, or (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU Affero General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU Affero General Public License
21
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
 */
23
24
declare(strict_types=1);
25
26
namespace OCA\CMSPico\AppInfo;
27
28
use OCA\CMSPico\Listener\ExternalStorageBackendEventListener;
29
use OCA\CMSPico\Listener\GroupDeletedEventListener;
30
use OCA\CMSPico\Listener\UserDeletedEventListener;
31
use OCP\App\AppPathNotFoundException;
32
use OCP\AppFramework\App;
33
use OCP\EventDispatcher\IEventDispatcher;
34
use OCP\Group\Events\GroupDeletedEvent;
35
use OCP\User\Events\UserDeletedEvent;
36
37
class Application extends App
38
{
39
	/** @var string */
40
	public const APP_NAME = 'cms_pico';
41
42
	/**
43
	 * @param array $urlParams
44
	 */
45
	public function __construct(array $urlParams = [])
46
	{
47
		parent::__construct(self::APP_NAME, $urlParams);
48
	}
49
50
	/**
51
	 * Registers event listeners.
52
	 */
53
	public function registerEventListener(): void
54
	{
55
		/** @var IEventDispatcher $eventDispatcher */
56
		$eventDispatcher = \OC::$server->query(IEventDispatcher::class);
0 ignored issues
show
Deprecated Code introduced by
The function OC\ServerContainer::query() has been deprecated: 20.0.0 use \Psr\Container\ContainerInterface::get ( Ignorable by Annotation )

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

56
		$eventDispatcher = /** @scrutinizer ignore-deprecated */ \OC::$server->query(IEventDispatcher::class);

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...
57
		$eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedEventListener::class);
58
		$eventDispatcher->addServiceListener(GroupDeletedEvent::class, GroupDeletedEventListener::class);
59
60
		$eventDispatcher->addServiceListener(
61
			'OCA\\Files_External::loadAdditionalBackends',
62
			ExternalStorageBackendEventListener::class
63
		);
64
	}
65
66
	/**
67
	 * Returns the absolute path to this app.
68
	 *
69
	 * @return string
70
	 */
71 6
	public static function getAppPath(): string
72
	{
73
		try {
74 6
			$appManager = \OC::$server->getAppManager();
0 ignored issues
show
Deprecated Code introduced by
The function OC\Server::getAppManager() has been deprecated: 20.0.0 ( Ignorable by Annotation )

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

74
			$appManager = /** @scrutinizer ignore-deprecated */ \OC::$server->getAppManager();

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...
75 6
			return $appManager->getAppPath(self::APP_NAME);
76
		} catch (AppPathNotFoundException $e) {
77
			return '';
78
		}
79
	}
80
81
	/**
82
	 * Returns the absolute web path to this app.
83
	 *
84
	 * @return string
85
	 */
86 5
	public static function getAppWebPath(): string
87
	{
88
		try {
89 5
			$appManager = \OC::$server->getAppManager();
0 ignored issues
show
Deprecated Code introduced by
The function OC\Server::getAppManager() has been deprecated: 20.0.0 ( Ignorable by Annotation )

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

89
			$appManager = /** @scrutinizer ignore-deprecated */ \OC::$server->getAppManager();

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...
90 5
			return $appManager->getAppWebPath(self::APP_NAME);
91
		} catch (AppPathNotFoundException $e) {
92
			return '';
93
		}
94
	}
95
96
	/**
97
	 * Returns the installed version of this app.
98
	 *
99
	 * @return string
100
	 */
101
	public static function getAppVersion(): string
102
	{
103
		try {
104
			$appManager = \OC::$server->getAppManager();
0 ignored issues
show
Deprecated Code introduced by
The function OC\Server::getAppManager() has been deprecated: 20.0.0 ( Ignorable by Annotation )

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

104
			$appManager = /** @scrutinizer ignore-deprecated */ \OC::$server->getAppManager();

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...
105
			return $appManager->getAppVersion(self::APP_NAME);
106
		} catch (AppPathNotFoundException $e) {
107
			return '';
108
		}
109
	}
110
}
111