Completed
Push — master ( 7ff1b8...399f52 )
by Jean-Christophe
03:04
created

HtmlSegmentGroups::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Ajax\semantic\html\elements;
4
5
use Ajax\semantic\html\base\constants\SegmentType;
6
use Ajax\semantic\html\base\HtmlSemCollection;
7
use Ajax\semantic\html\base\constants\Sens;
8
use Ajax\JsUtils;
9
10
class HtmlSegmentGroups extends HtmlSemCollection{
11
12
13
	public function __construct( $identifier, $items=array()){
14
		parent::__construct( $identifier, "div","ui segments");
15
		$this->addItems($items);
16
	}
17
18
19
	protected function createItem($value){
20
		return new HtmlSegment("segment-".$this->count(),$value);
21
	}
22
23
	protected function createCondition($value){
24
		return !($value instanceof HtmlSegment);
25
	}
26
27
	/**
28
	 * Defines the group type
29
	 * @param string $type one of "raised","stacked","piled" default : ""
30
	 * @return \Ajax\semantic\html\elements\HtmlSegmentGroups
31
	 */
32
	public function setType($type){
33
		return $this->addToPropertyCtrl("class", $type, SegmentType::getConstants());
34
	}
35
36
	public function setSens($sens=Sens::VERTICAL){
37
		return $this->addToPropertyCtrl("class", $sens, Sens::getConstants());
38
	}
39
40
	public function run(JsUtils $js){
41
		$result= parent::run($js);
42
		return $result->setItemSelector(".ui.segment");
43
	}
44
45
	public static function group($identifier,$items=array(),$type="",$sens=Sens::VERTICAL){
46
		$group=new HtmlSegmentGroups($identifier,$items);
47
		$group->setSens($sens);
48
		return $group->setType($type);
49
	}
50
51
}