Total Complexity | 43 |
Total Lines | 53 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
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 |
||
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) {} |
||
16 | public function setPassword($password) {} |
||
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 | } |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.