Completed
Push — master ( 73e21a...085edf )
by Jean-Christophe
04:37
created

HtmlStepItem   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 48
Duplicated Lines 22.92 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 11
c 2
b 0
f 0
lcom 1
cbo 3
dl 11
loc 48
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
B initContent() 11 26 6
A setActive() 0 3 1
A setCompleted() 0 3 1
A setStatus() 0 3 1
A removeStatus() 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
namespace Ajax\semantic\html\content;
4
5
use Ajax\service\JArray;
6
use Ajax\semantic\html\base\constants\StepStatus;
7
8
class HtmlStepItem extends HtmlAbsractItem {
9
10
	public function __construct($identifier, $content) {
11
		parent::__construct($identifier,"step",$content);
12
	}
13
	protected function initContent($content){
14
		if(\is_array($content)){
15 View Code Duplication
			if(JArray::isAssociative($content)===false){
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
16
				$icon=@$content[0];
17
				$title=@$content[1];
18
				$desc=@$content[2];
19
				$status=@$content[3];
20
			}else{
21
				$icon=@$content["icon"];
22
				$title=@$content["title"];
23
				$desc=@$content["description"];
24
				$status=@$content["status"];
25
			}
26
			if(isset($icon)===true){
27
				$this->setIcon($icon);
28
			}
29
			if(isset($status)===true){
30
				$this->setStatus($status);
31
			}
32
			if(isset($title)===true){
33
				$this->setTitle($title,$desc);
34
			}
35
		}else{
36
			$this->setContent($content);
37
		}
38
	}
39
40
	public function setActive(){
41
		return $this->setStatus(StepStatus::ACTIVE);
42
	}
43
44
	public function setCompleted(){
45
		return $this->setStatus(StepStatus::COMPLETED);
46
	}
47
48
	public function setStatus($status){
49
		return $this->addToPropertyCtrl("class", $status, StepStatus::getConstants());
50
	}
51
52
	public function removeStatus(){
53
		$this->removePropertyValues("class", StepStatus::getConstants());
54
	}
55
}