OpauthMemberLoginFormExtension   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 5
dl 0
loc 36
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A forgotPassword() 0 20 4
1
<?php
2
class OpauthMemberLoginFormExtension extends Extension {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
3
4
	/**
5
	 * @config
6
	 * @var boolean
7
	 */
8
	private static $allow_password_reset = true;
0 ignored issues
show
Unused Code introduced by
The property $allow_password_reset is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
9
10
	/**
11
	 * Deny password resets
12
	 * 
13
	 * @param Member $member
14
	 * @return boolean
15
	 */
16
	public function forgotPassword($member) {
17
		if(Config::inst()->get('OpauthMemberLoginFormExtension', 'allow_password_reset')) {
18
			return null;
19
		}
20
21
		$identity = OpauthIdentity::get()->find('MemberID', $member->ID);
22
		if(!$member->Password && $identity) {
23
			$this->owner->sessionMessage(
24
				_t(
25
					'OpauthMemberLoginFormExtension.NoResetPassword',
26
					'Can\'t reset password for accounts registered through {provider}',
27
					array('provider' => $identity->Provider)
0 ignored issues
show
Documentation introduced by
array('provider' => $identity->Provider) is of type array<string,?,{"provider":"?"}>, 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...
28
				),
29
				'bad'
30
			);
31
			return false;
32
		} else {
33
			return null;
34
		}
35
	}
36
37
}