Completed
Push — master ( 3d671c...42e805 )
by Blizzz
48:26 queued 33:21
created

Application   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 60.87 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
dl 14
loc 23
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 14 21 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * @copyright Copyright (c) 2017 Roger Szabo <[email protected]>
4
 *
5
 * @author Roger Szabo <[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\User_LDAP\AppInfo;
25
26
use OCA\User_LDAP\Controller\RenewPasswordController;
27
use OCP\AppFramework\App;
28
use OCP\AppFramework\IAppContainer;
29
30
class Application extends App {
31
	public function __construct () {
32
		parent::__construct('user_ldap');
33
		$container = $this->getContainer();
34
35
		/**
36
		 * Controller
37
		 */
38 View Code Duplication
		$container->registerService('RenewPasswordController', function(IAppContainer $c) {
39
			/** @var \OC\Server $server */
40
			$server = $c->query('ServerContainer');
41
42
			return new RenewPasswordController(
0 ignored issues
show
Bug introduced by
The call to RenewPasswordController::__construct() misses a required argument $urlGenerator.

This check looks for function calls that miss required arguments.

Loading history...
43
				$c->getAppName(),
44
				$server->getRequest(),
45
				$c->query('UserManager'),
46
				$server->getConfig(),
47
				$c->query('OCP\IL10N'),
48
				$server->getURLGenerator()
0 ignored issues
show
Documentation introduced by
$server->getURLGenerator() is of type object<OCP\IURLGenerator>, but the function expects a object<OCP\ISession>.

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...
49
			);
50
		});
51
	}
52
}
53