Completed
Push — master ( e6529d...cd0fd2 )
by Jean-Christophe
03:35
created

HtmlGridCol   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 38
Duplicated Lines 18.42 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 7
c 4
b 0
f 0
lcom 0
cbo 3
dl 7
loc 38
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A setWidth() 7 7 2
A setFloated() 0 3 1
A setTextAlignment() 0 3 1
A setValue() 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\semantic\html\base\HtmlSemDoubleElement;
6
use Ajax\semantic\html\base\Wide;
7
use Ajax\semantic\html\base\TextAlignment;
8
9
/**
10
 * A col in the Semantic Grid component
11
 * @see http://semantic-ui.com/collections/grid.html
12
 * @author jc
13
 * @version 1.001
14
 */
15
class HtmlGridCol extends HtmlSemDoubleElement{
16
	public function __construct($identifier,$width){
17
		parent::__construct($identifier,"div");
18
		$this->setClass("column");
19
		if(isset($width))
20
			$this->setWidth($width);
21
	}
22
23
	/**
24
	 * Defines the col width
25
	 * @param int $width
26
	 * @return \Ajax\semantic\html\content\HtmlGridCol
27
	 */
28 View Code Duplication
	public function setWidth($width){
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...
29
		if(\is_int($width)){
30
			$width=Wide::getConstants()["W".$width];
31
		}
32
		$this->addToPropertyCtrl("class", $width, Wide::getConstants());
33
		return $this->addToPropertyCtrl("class", "wide",array("wide"));
34
	}
35
36
	/**
37
	 * Defines the coll floating
38
	 * @param string $value left or right
39
	 * @return \Ajax\semantic\html\content\HtmlGridCol
40
	 */
41
	public function setFloated($value="left"){
42
		return $this->addToProperty("class", $value." floated");
43
	}
44
45
	public function setTextAlignment($value=TextAlignment::LEFT){
46
		return $this->addToPropertyCtrl("class", $value,TextAlignment::getConstants());
47
	}
48
49
	public function setValue($value){
50
		$this->content=$value;
51
	}
52
}