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

HtmlSegmentGroups   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 35
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A createItem() 0 3 1
A setType() 0 3 1
A setSens() 0 3 1
A group() 0 5 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
}