MockUser   B
last analyzed

Complexity

Total Complexity 43

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 43
eloc 4
c 1
b 0
f 0
dl 0
loc 53
rs 8.96

43 Methods

Rating   Name   Duplication   Size   Complexity  
A validatePassword() 0 1 1
A getIdHash() 0 1 1
A setPassword() 0 1 1
A findByEmail() 0 1 1
A removeChangeEmailToken() 0 1 1
A isTokenConfirmed() 0 1 1
A removeVerifyEmailToken() 0 1 1
A generateVerifyEmailToken() 0 1 1
A isTokenCurrent() 0 1 1
A generateChangeEmailToken() 0 1 1
A getPartnerEmails() 0 1 1
A findByChangeEmailToken() 0 1 1
A sendEmailReport() 0 1 1
A confirmVerifyEmailToken() 0 1 1
A getAuthKey() 0 1 1
A findOne() 0 1 1
A updateAll() 0 1 1
A findIdentityByAccessToken() 0 1 1
A setAttribute() 0 1 1
A getIsNewRecord() 0 1 1
A primaryKey() 0 1 1
A attributes() 0 1 1
A getRelation() 0 1 1
A getOldPrimaryKey() 0 1 1
A link() 0 1 1
A getAttribute() 0 1 1
A deleteAll() 0 1 1
A update() 0 1 1
A equals() 0 1 1
A findIdentity() 0 1 1
A findAll() 0 1 1
A populateRelation() 0 1 1
A unlink() 0 1 1
A validateAuthKey() 0 1 1
A save() 0 1 1
A getPrimaryKey() 0 1 1
A delete() 0 1 1
A find() 0 1 1
A getId() 0 1 1
A insert() 0 1 1
A hasAttribute() 0 1 1
A getDb() 0 1 1
A isPrimaryKey() 0 1 1

How to fix   Complexity   

Complex Class

Complex classes like MockUser often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use MockUser, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace site\tests\_support;
4
class MockUser implements \common\interfaces\UserInterface, \yii\web\IdentityInterface {
5
  use \yii\base\StaticInstanceTrait;
6
    
7
  public $timezone = 'America/Los_Angeles';
8
  public $password;
9
10
 public static function findIdentity($id) {}
11
 public static function findIdentityByAccessToken($token, $type = null) {}
12
 public function getId() {}
13
 public function getAuthKey() {}
14
 public function validateAuthKey($authKey) {}
15
 public function validatePassword($password) {}
0 ignored issues
show
Unused Code introduced by
The parameter $password is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

15
 public function validatePassword(/** @scrutinizer ignore-unused */ $password) {}

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
16
 public function setPassword($password) {}
0 ignored issues
show
Unused Code introduced by
The parameter $password is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

16
 public function setPassword(/** @scrutinizer ignore-unused */ $password) {}

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
17
18
  public static function primaryKey() {}
19
  public function attributes() {}
20
  public function getAttribute($name) {}
21
  public function setAttribute($name, $value) {}
22
  public function hasAttribute($name) {}
23
  public function getPrimaryKey($asArray = false) {}
24
  public function getOldPrimaryKey($asArray = false) {}
25
  public static function isPrimaryKey($keys) {}
26
  public static function find() {}
27
  public static function findOne($condition) {}
28
  public static function findAll($condition) {}
29
  public static function updateAll($attributes, $condition = null) {}
30
  public static function deleteAll($condition = null) {}
31
  public function save($runValidation = true, $attributeNames = null) {}
32
  public function insert($runValidation = true, $attributes = null) {}
33
  public function update($runValidation = true, $attributeNames = null) {}
34
  public function delete() {}
35
  public function getIsNewRecord() {}
36
  public function equals($record) {}
37
  public function getRelation($name, $throwException = true) {}
38
  public function populateRelation($name, $records) {}
39
  public function link($name, $model, $extraColumns = []) {}
40
  public function unlink($name, $model, $delete = false) {}
41
  public static function getDb() {}
42
  public function getIdHash() {}
43
  public function findByEmail($email) {}
44
45
  public function sendEmailReport($date) {}
46
  public function getPartnerEmails() {}
47
  public function isTokenCurrent($token, String $paramPath) {}
48
  public function isTokenConfirmed($token, String $match) {}
49
50
  public function generateChangeEmailToken() {}
51
  public function removeChangeEmailToken() {}
52
  public function findByChangeEmailToken($email) {}
53
54
  public function generateVerifyEmailToken() {}
55
  public function confirmVerifyEmailToken() {}
56
  public function removeVerifyEmailToken() {}
57
}