Completed
Push — master ( fda645...92bd71 )
by Jean-Christophe
04:17
created

FormAccount   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 58
Duplicated Lines 46.55 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
lcom 1
cbo 2
dl 27
loc 58
rs 10
c 1
b 0
f 1

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getDefaultModelInstance() 0 3 1
A regular() 0 14 1
A smallInline() 10 10 1
A small() 10 10 1
A attachedSegment() 7 7 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
namespace Ajax\semantic\widgets\business\user;
3
use Ajax\semantic\widgets\business\BusinessForm;
4
/**
5
 * Form for user Account
6
 * @author jc
7
 */
8
class FormAccount extends BusinessForm {
9
	/**
10
	 * @param string $identifier
11
	 * @param object $modelInstance
12
	 */
13
	public function __construct($identifier,$modelInstance=null,$fieldsOrder=[],$fieldsDefinition=[],$fields=[],$captions=[],$separators=[]) {
14
		parent::__construct($identifier,$modelInstance,$fieldsOrder,$fieldsDefinition,$fields,$captions,$separators);
15
	}
16
17
	protected function getDefaultModelInstance(){
18
		return new UserModel();
19
	}
20
21
	public static function regular($identifier,$modelInstance=null){
22
		return new FormAccount($identifier,$modelInstance,
23
				["message","login","password","passwordConf","email","submit","error"],
24
				["message"=>[["icon"=>"sign in"]],
25
						"input0"=>[["rules"=>"empty"]],
26
						"input1"=>[["inputType"=>"password","rules"=> ['minLength[6]', 'empty']]],
27
						"input2"=>[["inputType"=>"password","rules"=> ['minLength[6]', 'empty', 'match[password]']]],
28
						"input3"=>[["rules"=>"email"]],
29
						"submit"=>["green fluid"],
30
						"message2"=>[["error"=>true]]],
31
				["Account","login","password","passwordConf","email","submit","error"],
32
				["Please enter your account informations","Login","Password","Password confirmation","Email address","Creation"],
33
				[0,1,3,4,5,6]);
34
	}
35
36 View Code Duplication
	public static function smallInline($identifier,$modelInstance=null){
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
37
		$result=new FormAccount($identifier,$modelInstance,
38
				["login","password","submit"],
39
				["input0"=>[["rules"=>"empty"]],"input1"=>[["inputType"=>"password","rules"=>"empty"]],"submit"=>["green basic"]],
40
				["login","password","submit"],
41
				["","","Connection"],
42
				[2]);
43
			$result->addDividerBefore(0, "Connection");
44
		return $result;
45
	}
46
47 View Code Duplication
	public static function small($identifier,$modelInstance=null){
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
		$result=new FormAccount($identifier,$modelInstance,
49
				["login","password","submit"],
50
				["input0"=>[["rules"=>"empty"]],"input1"=>[["inputType"=>"password","rules"=>"empty"]],"submit"=>["green basic"]],
51
				["login","password","submit"],
52
				["Login","Password","Connection"],
53
				[1,2]);
54
		$result->addDividerBefore(0, "Connection");
55
		return $result;
56
	}
57
58 View Code Duplication
	public static function attachedSegment($identifier,$modelInstance=null){
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
59
		$result=self::regular($identifier,$modelInstance);
60
		$result->fieldAsMessage("message",["icon"=>"sign in","attached"=>true]);
61
		$result->addWrapper("message",null,"<div class='ui attached segment'>");
62
		$result->addWrapper("error", null,"</div>");
63
		return $result;
64
	}
65
}
66