Completed
Push — master ( db82f0...0ba4b1 )
by Jean-Christophe
03:22
created

HtmlGridCol   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 19.44 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 5
Bugs 0 Features 0
Metric Value
wmc 6
c 5
b 0
f 0
lcom 0
cbo 3
dl 7
loc 36
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A setWidth() 7 7 2
A setFloated() 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\constants\Wide;
7
use Ajax\semantic\html\base\traits\TextAlignmentTrait;
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
	use TextAlignmentTrait;
17
	public function __construct($identifier,$width){
18
		parent::__construct($identifier,"div");
19
		$this->setClass("column");
20
		if(isset($width))
21
			$this->setWidth($width);
22
	}
23
24
	/**
25
	 * Defines the col width
26
	 * @param int $width
27
	 * @return \Ajax\semantic\html\content\HtmlGridCol
28
	 */
29 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...
30
		if(\is_int($width)){
31
			$width=Wide::getConstants()["W".$width];
32
		}
33
		$this->addToPropertyCtrl("class", $width, Wide::getConstants());
34
		return $this->addToPropertyCtrl("class", "wide",array("wide"));
35
	}
36
37
	/**
38
	 * Defines the coll floating
39
	 * @param string $value left or right
40
	 * @return \Ajax\semantic\html\content\HtmlGridCol
41
	 */
42
	public function setFloated($value="left"){
43
		return $this->addToProperty("class", $value." floated");
44
	}
45
46
47
	public function setValue($value){
48
		$this->content=$value;
49
	}
50
}