Completed
Push — master ( 94010e...d161d4 )
by Morris
17:23
created

Server::getForm()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 0
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * @copyright Copyright (c) 2016 Arthur Schiwon <[email protected]>
4
 *
5
 * @author Arthur Schiwon <[email protected]>
6
 * @author Joas Schilling <[email protected]>
7
 * @author Lukas Reschke <[email protected]>
8
 * @author Morris Jobke <[email protected]>
9
 *
10
 * @license GNU AGPL version 3 or any later version
11
 *
12
 * This program is free software: you can redistribute it and/or modify
13
 * it under the terms of the GNU Affero General Public License as
14
 * published by the Free Software Foundation, either version 3 of the
15
 * License, or (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU Affero General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU Affero General Public License
23
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
24
 *
25
 */
26
27
namespace OC\Settings\Admin;
28
29
use Doctrine\DBAL\Connection;
30
use Doctrine\DBAL\DBALException;
31
use Doctrine\DBAL\Platforms\SqlitePlatform;
32
use OC\Lock\DBLockingProvider;
33
use OC\Lock\NoopLockingProvider;
34
use OCP\AppFramework\Http\TemplateResponse;
35
use OCP\IConfig;
36
use OCP\IDBConnection;
37
use OCP\IL10N;
38
use OCP\IRequest;
39
use OCP\Lock\ILockingProvider;
40
use OCP\Settings\ISettings;
41
42
class Server implements ISettings {
43
	/** @var IDBConnection|Connection */
44
	private $db;
45
	/** @var IRequest */
46
	private $request;
47
	/** @var IConfig */
48
	private $config;
49
	/** @var ILockingProvider */
50
	private $lockingProvider;
51
	/** @var IL10N */
52
	private $l;
53
54
	/**
55
	 * @param IDBConnection $db
56
	 * @param IRequest $request
57
	 * @param IConfig $config
58
	 * @param ILockingProvider $lockingProvider
59
	 * @param IL10N $l
60
	 */
61 View Code Duplication
	public function __construct(IDBConnection $db,
62
								IRequest $request,
63
								IConfig $config,
64
								ILockingProvider $lockingProvider,
65
								IL10N $l) {
66
		$this->db = $db;
67
		$this->request = $request;
68
		$this->config = $config;
69
		$this->lockingProvider = $lockingProvider;
70
		$this->l = $l;
71
	}
72
73
	/**
74
	 * @return TemplateResponse
75
	 */
76
	public function getForm() {
77
		$parameters = [
78
			// Background jobs
79
			'backgroundjobs_mode' => $this->config->getAppValue('core', 'backgroundjobs_mode', 'ajax'),
80
			'lastcron'            => $this->config->getAppValue('core', 'lastcron', false),
0 ignored issues
show
Documentation introduced by
false is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
81
			'cronErrors'		  => $this->config->getAppValue('core', 'cronErrors'),
82
			'cli_based_cron_possible' => function_exists('posix_getpwuid'),
83
			'cli_based_cron_user' => function_exists('posix_getpwuid') ? posix_getpwuid(fileowner(\OC::$configDir . 'config.php'))['name'] : '',
84
		];
85
86
		return new TemplateResponse('settings', 'settings/admin/server', $parameters, '');
87
	}
88
89
	/**
90
	 * @return string the section ID, e.g. 'sharing'
91
	 */
92
	public function getSection() {
93
		return 'server';
94
	}
95
96
	/**
97
	 * @return int whether the form should be rather on the top or bottom of
98
	 * the admin section. The forms are arranged in ascending order of the
99
	 * priority values. It is required to return a value between 0 and 100.
100
	 *
101
	 * E.g.: 70
102
	 */
103
	public function getPriority() {
104
		return 0;
105
	}
106
}
107