Completed
Push — master ( 189ad5...73e21a )
by Jean-Christophe
04:04
created

HtmlSegment   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 6

Importance

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

10 Methods

Rating   Name   Duplication   Size   Complexity  
A setCircular() 0 3 1
A clear() 0 3 1
A __construct() 0 6 1
A setType() 0 3 1
A setSens() 0 3 1
A setEmphasis() 0 3 1
A setCompact() 0 3 1
A setBasic() 0 3 1
A asContainer() 0 3 1
A addGrid() 0 5 1
1
<?php
2
3
namespace Ajax\semantic\html\elements;
4
5
use Ajax\semantic\html\base\HtmlSemDoubleElement;
6
use Ajax\semantic\html\base\constants\SegmentType;
7
use Ajax\semantic\html\base\traits\AttachedTrait;
8
use Ajax\semantic\html\base\constants\State;
9
use Ajax\semantic\html\base\constants\Variation;
10
use Ajax\semantic\html\base\constants\Emphasis;
11
use Ajax\semantic\html\base\traits\TextAlignmentTrait;
12
use Ajax\semantic\html\collections\HtmlGrid;
13
14
/**
15
 * Semantic Segment element
16
 * @see http://semantic-ui.com/elements/segment.html
17
 * @author jc
18
 * @version 1.001
19
 */
20
class HtmlSegment extends HtmlSemDoubleElement {
21
	use AttachedTrait,TextAlignmentTrait;
22
23
	public function __construct($identifier, $content="") {
24
		parent::__construct($identifier, "div", "ui segment");
25
		$this->_variations=\array_merge($this->_variations, [ Variation::PADDED,Variation::COMPACT ]);
26
		$this->_states=\array_merge($this->_states, [ State::LOADING ]);
27
		$this->content=$content;
28
	}
29
30
	/**
31
	 * Defines the segment type
32
	 * @param string $type one of "raised","stacked","piled" default : ""
33
	 * @return \Ajax\semantic\html\elements\HtmlSegment
34
	 */
35
	public function setType($type) {
36
		return $this->addToPropertyCtrl("class", $type, SegmentType::getConstants());
37
	}
38
39
	public function setSens($sens="vertical") {
40
		return $this->addToPropertyCtrl("class", $sens, array ("vertical","horizontal" ));
41
	}
42
43
	public function setEmphasis($value=Emphasis::SECONDARY) {
44
		return $this->addToPropertyCtrl("class", $value, Emphasis::getConstants());
45
	}
46
47
	public function setCircular() {
48
		return $this->addToProperty("class", "circular");
49
	}
50
51
	public function clear() {
52
		return $this->addToProperty("class", "clearing");
53
	}
54
55
	public function setCompact() {
56
		return $this->addToProperty("class", "compact");
57
	}
58
59
	public function setBasic() {
60
		return $this->setProperty("class", "ui basic segment");
61
	}
62
63
	public function asContainer() {
64
		return $this->addToPropertyCtrl("class", "container", array ("container" ));
65
	}
66
67
	public function addGrid($numRows=1, $numCols=NULL){
68
		$grid=new HtmlGrid("Grid-".$this->identifier,$numRows,$numCols);
69
		$this->content=$grid;
70
		return $grid;
71
	}
72
}