Admin::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 0
cts 13
cp 0
rs 9.8333
c 0
b 0
f 0
cc 1
nc 1
nop 5
crap 2
1
<?php
2
/**
3
 * @copyright Copyright (c) 2016 Lukas Reschke <[email protected]>
4
 *
5
 * @author Lukas Reschke <[email protected]>
6
 *
7
 * @license GNU AGPL version 3 or any later version
8
 *
9
 * This program is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU Affero General Public License as
11
 * published by the Free Software Foundation, either version 3 of the
12
 * License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU Affero General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Affero General Public License
20
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 *
22
 */
23
24
namespace OCA\Richdocuments\Settings;
25
26
use OCA\Richdocuments\AppConfig;
27
use OCA\Richdocuments\Capabilities;
28
use OCA\Richdocuments\Service\DemoService;
29
use OCA\Richdocuments\TemplateManager;
30
use OCP\AppFramework\Http\TemplateResponse;
31
use OCP\IConfig;
32
use OCP\Settings\ISettings;
33
34
class Admin implements ISettings {
35
36
	/** @var IConfig */
37
	private $config;
38
39
	/** @var AppConfig */
40
	private $appConfig;
41
42
	/** @var TemplateManager */
43
	private $manager;
44
45
	/** @var array */
46
	private $capabilities;
47
48
	/** @var DemoService */
49
	private $demoService;
50
51
	/**
52
	 * Admin template settings
53
	 *
54
	 * @param IConfig $config
55
	 * @param TemplateManager $manager
56
	 * @param Capabilities $capabilities
57
	 */
58
	public function __construct(
59
		IConfig $config,
60
		AppConfig $appConfig,
61
		TemplateManager $manager,
62
		Capabilities $capabilities,
63
		DemoService $demoService
64
	) {
65
		$this->config  = $config;
66
		$this->appConfig = $appConfig;
67
		$this->manager = $manager;
68
		$this->capabilities = $capabilities->getCapabilities()['richdocuments'];
69
		$this->demoService = $demoService;
70
	}
71
	/**
72
	 * @return TemplateResponse
73
	 */
74
	public function getForm() {
75
		$demoServers = [];
0 ignored issues
show
Unused Code introduced by
$demoServers is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
76
77
		return new TemplateResponse(
78
			'richdocuments',
79
			'admin',
80
			[
81
				'settings' => [
82
					'wopi_url'           => $this->config->getAppValue('richdocuments', 'wopi_url'),
83
					'edit_groups'        => $this->config->getAppValue('richdocuments', 'edit_groups'),
84
					'use_groups'         => $this->config->getAppValue('richdocuments', 'use_groups'),
85
					'doc_format'         => $this->config->getAppValue('richdocuments', 'doc_format'),
86
					'external_apps'      => $this->config->getAppValue('richdocuments', 'external_apps'),
87
					'canonical_webroot'  => $this->config->getAppValue('richdocuments', 'canonical_webroot'),
88
					'disable_certificate_verification' => $this->config->getAppValue('richdocuments', 'disable_certificate_verification', '') === 'yes',
89
					'templates'          => $this->manager->getSystemFormatted(),
90
					'templatesAvailable' => array_key_exists('templates', $this->capabilities) && $this->capabilities['templates'],
91
					'settings' => $this->appConfig->getAppSettings(),
92
					'demo_servers' => $this->demoService->fetchDemoServers(),
93
					'web_server' => strtolower($_SERVER['SERVER_SOFTWARE']),
94
					'os_family' => PHP_VERSION_ID >= 70200 ? PHP_OS_FAMILY : PHP_OS,
95
					'platform' => php_uname('m')
96
				]
97
			],
98
			'blank'
99
		);
100
	}
101
	/**
102
	 * @return string the section ID, e.g. 'sharing'
103
	 */
104
	public function getSection() {
105
		return 'richdocuments';
106
	}
107
	/**
108
	 * @return int whether the form should be rather on the top or bottom of
109
	 * the admin section. The forms are arranged in ascending order of the
110
	 * priority values. It is required to return a value between 0 and 100.
111
	 *
112
	 * keep the server setting at the top, right after "server settings"
113
	 */
114
	public function getPriority() {
115
		return 0;
116
	}
117
118
}
119