AbstractSecondaryAuthenticationProvider   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 57
Duplicated Lines 15.79 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 9
loc 57
rs 10
c 0
b 0
f 0
wmc 12
lcom 0
cbo 3

11 Methods

Rating   Name   Duplication   Size   Complexity  
A continueSecondaryAuthentication() 0 3 1
A postAuthentication() 0 2 1
A providerAllowsPropertyChange() 0 3 1
A providerRevokeAccessForUser() 9 9 2
A providerAllowsAuthenticationDataChange() 0 5 1
A providerChangeAuthenticationData() 0 2 1
A testForAccountCreation() 0 3 1
A continueSecondaryAccountCreation() 0 3 1
A postAccountCreation() 0 2 1
A autoCreatedAccount() 0 2 1
A testUserForCreation() 0 3 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
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License as published by
5
 * the Free Software Foundation; either version 2 of the License, or
6
 * (at your option) any later version.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
 * GNU General Public License for more details.
12
 *
13
 * You should have received a copy of the GNU General Public License along
14
 * with this program; if not, write to the Free Software Foundation, Inc.,
15
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16
 * http://www.gnu.org/copyleft/gpl.html
17
 *
18
 * @file
19
 * @ingroup Auth
20
 */
21
22
namespace MediaWiki\Auth;
23
24
/**
25
 * A base class that implements some of the boilerplate for a SecondaryAuthenticationProvider
26
 *
27
 * @ingroup Auth
28
 * @since 1.27
29
 */
30
abstract class AbstractSecondaryAuthenticationProvider extends AbstractAuthenticationProvider
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces between "AbstractAuthenticationProvider" and comma; 1 found
Loading history...
31
	implements SecondaryAuthenticationProvider
0 ignored issues
show
Coding Style introduced by
The implements keyword must be on the same line as the class name
Loading history...
32
{
33
34
	public function continueSecondaryAuthentication( $user, array $reqs ) {
35
		throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
36
	}
37
38
	public function postAuthentication( $user, AuthenticationResponse $response ) {
39
	}
40
41
	public function providerAllowsPropertyChange( $property ) {
42
		return true;
43
	}
44
45
	/**
46
	 * @inheritdoc
47
	 * @note Reimplement this if self::getAuthenticationRequests( AuthManager::ACTION_REMOVE )
48
	 *  doesn't return requests that will revoke all access for the user.
49
	 */
50 View Code Duplication
	public function providerRevokeAccessForUser( $username ) {
51
		$reqs = $this->getAuthenticationRequests(
52
			AuthManager::ACTION_REMOVE, [ 'username' => $username ]
53
		);
54
		foreach ( $reqs as $req ) {
55
			$req->username = $username;
56
			$this->providerChangeAuthenticationData( $req );
57
		}
58
	}
59
60
	public function providerAllowsAuthenticationDataChange(
61
		AuthenticationRequest $req, $checkData = true
62
	) {
63
		return \StatusValue::newGood( 'ignored' );
64
	}
65
66
	public function providerChangeAuthenticationData( AuthenticationRequest $req ) {
67
	}
68
69
	public function testForAccountCreation( $user, $creator, array $reqs ) {
70
		return \StatusValue::newGood();
71
	}
72
73
	public function continueSecondaryAccountCreation( $user, $creator, array $reqs ) {
74
		throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
75
	}
76
77
	public function postAccountCreation( $user, $creator, AuthenticationResponse $response ) {
78
	}
79
80
	public function testUserForCreation( $user, $autocreate, array $options = [] ) {
81
		return \StatusValue::newGood();
82
	}
83
84
	public function autoCreatedAccount( $user, $source ) {
85
	}
86
}
87