Completed
Push — master ( 8b7375...189ad5 )
by Jean-Christophe
03:49
created

HtmlGridCol   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 42
Duplicated Lines 16.67 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 8
Bugs 0 Features 0
Metric Value
wmc 8
c 8
b 0
f 0
lcom 1
cbo 4
dl 7
loc 42
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A setWidth() 7 7 2
A setValue() 0 4 1
A setValues() 0 3 1
A addDivider() 0 9 2

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
use Ajax\semantic\html\base\constants\Direction;
9
use Ajax\semantic\html\elements\HtmlDivider;
10
11
/**
12
 * A col in the Semantic Grid component
13
 * @see http://semantic-ui.com/collections/grid.html
14
 * @author jc
15
 * @version 1.001
16
 */
17
class HtmlGridCol extends HtmlSemDoubleElement {
18
	use TextAlignmentTrait;
19
20
	public function __construct($identifier, $width=NULL) {
21
		parent::__construct($identifier, "div");
22
		$this->setClass("column");
23
		if (isset($width))
24
			$this->setWidth($width);
25
	}
26
27
	/**
28
	 * Defines the col width
29
	 * @param int $width
30
	 * @return \Ajax\semantic\html\content\HtmlGridCol
31
	 */
32 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...
33
		if (\is_int($width)) {
34
			$width=Wide::getConstants()["W" . $width];
35
		}
36
		$this->addToPropertyCtrl("class", $width, Wide::getConstants());
37
		return $this->addToPropertyCtrl("class", "wide", array ("wide" ));
38
	}
39
40
	public function setValue($value) {
41
		$this->content=$value;
42
		return $this;
43
	}
44
45
	public function setValues($value) {
46
		return $this->setValue($value);
47
	}
48
49
	public function addDivider($vertical=true, $content=NULL) {
50
		$divider=new HtmlDivider("", $content);
51
		if ($vertical)
52
			$divider->setVertical();
53
		else
54
			$divider->setHorizontal();
55
		$this->wrap("", $divider);
56
		return $divider;
57
	}
58
}