Completed
Push — master ( 8466ff...9e5b24 )
by Jean-Christophe
03:04
created

HtmlGridCol   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 23.33 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
lcom 0
cbo 2
dl 7
loc 30
rs 10

3 Methods

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