Completed
Push — master ( 9de830...b49918 )
by Jean-Christophe
03:44
created

HtmlForm::createItem()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
3
namespace Ajax\semantic\html\collections\form;
4
5
use Ajax\semantic\html\base\HtmlSemCollection;
6
use Ajax\service\JArray;
7
8
class HtmlForm extends HtmlSemCollection{
9
10
11
	public function __construct( $identifier, $elements=array()){
12
		parent::__construct( $identifier, "form", "ui form");
13
		$this->setProperty("name", $this->identifier);
14
		$this->addItems($elements);
15
	}
16
17
18
	protected function createItem($value){
19
		if(\is_array($value)){
20
			$itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id",""),JArray::getDefaultValue($value, "label",null),JArray::getDefaultValue($value, "type", "text"),JArray::getDefaultValue($value, "value",""),JArray::getDefaultValue($value, "placeholder",JArray::getDefaultValue($value, "label",null)));
21
			return $itemO;
22
		}else
23
		return new HtmlFormInput($value);
24
	}
25
26
}