Completed
Push — master ( 73e21a...085edf )
by Jean-Christophe
04:37
created

HtmlLabelGroups::createItem()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 2
eloc 10
nc 2
nop 1
1
<?php
2
3
namespace Ajax\semantic\html\elements;
4
5
use Ajax\semantic\html\base\HtmlSemCollection;
6
use Ajax\service\JArray;
7
use Ajax\semantic\html\base\constants\Size;
8
use Ajax\semantic\html\base\constants\Color;
9
10
/**
11
 * Semantic Label groups component
12
 * @see http://semantic-ui.com/elements/label.html#/definition
13
 * @author jc
14
 * @version 1.001
15
 */
16
class HtmlLabelGroups extends HtmlSemCollection {
17
18
	public function __construct($identifier,$labels=array(), $attributes=array()) {
19
		parent::__construct($identifier, "div", "ui labels");
20
		$this->_states=\array_merge(Size::getConstants(),Color::getConstants(),["tag","circular"]);
21
		$this->addItems($labels);
22
		$this->setStates($attributes);
23
	}
24
25
	protected function createItem($value) {
26
		$caption=$value;
27
		$icon=NULL;
28
		$tagName="div";
29
		if (\is_array($value)) {
30
			$caption=JArray::getValue($value, "caption", 0);
31
			$icon=JArray::getValue($value, "icon", 1);
32
			$tagName=JArray::getValue($value, "tagName", 2);
33
		}
34
		$labelO=new HtmlLabel("label-" . $this->identifier, $caption,$icon,$tagName);
35
		return $labelO;
36
	}
37
38
	protected function createCondition($value) {
39
		return ($value instanceof HtmlLabel) === false;
40
	}
41
42
}