Completed
Push — master ( 195df7...541276 )
by Jean-Christophe
03:05
created

HtmlSegmentGroups::setType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Ajax\semantic\html\elements;
4
5
use Ajax\common\html\html5\HtmlCollection;
6
use Ajax\semantic\html\base\SegmentType;
7
8
class HtmlSegmentGroups extends HtmlCollection{
9
10
11
	public function __construct( $identifier, $items=array()){
12
		parent::__construct( $identifier, "div");
13
		$this->setClass("ui segments");
14
		$this->addItems($items);
15
	}
16
17
18
	protected function createItem($value){
19
		return new HtmlSegment("segment-".$this->count(),$value);
0 ignored issues
show
Bug introduced by
It seems like $value defined by parameter $value on line 18 can also be of type object<Ajax\common\html\HtmlDoubleElement>; however, Ajax\semantic\html\eleme...lSegment::__construct() does only seem to accept string, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
20
	}
21
22
	/**
23
	 * Defines the group type
24
	 * @param string $type one of "raised","stacked","piled" default : ""
25
	 * @return \Ajax\semantic\html\elements\HtmlSegmentGroups
26
	 */
27
	public function setType($type){
28
		return $this->addToPropertyCtrl("class", $type, SegmentType::getConstants());
29
	}
30
31
	public function setSens($sens="vertical"){
32
		return $this->addToPropertyCtrl("class", $sens, array("vertical","horizontal"));
33
	}
34
35
36
	public static function group($identifier,$items=array(),$type="",$sens="vertical"){
37
		$group=new HtmlSegmentGroups($identifier,$items);
38
		$group->setSens($sens);
39
		return $group->setType($type);
40
	}
41
42
}