Completed
Push — master ( 80f966...5d65dd )
by Jean-Christophe
03:20
created

HtmlFormDropdown   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 24
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setItems() 0 3 1
A addItem() 0 3 1
A getDataField() 0 3 1
A __construct() 0 3 1
A multipleDropdown() 0 3 1
A asSelect() 0 4 1
1
<?php
2
3
namespace Ajax\semantic\html\collections\form;
4
5
use Ajax\semantic\html\collections\form\HtmlFormField;
6
use Ajax\semantic\html\modules\HtmlDropdown;
7
8
class HtmlFormDropdown extends HtmlFormField {
9
10
	public function __construct($identifier,$items=array(), $label=NULL,$value=NULL,$multiple=false,$associative=true) {
11
		parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier,$value,$items,$associative))->asSelect($identifier,$multiple), $label);
12
	}
13
14
	public function setItems($items){
15
		return $this->getField()->setItems($items);
16
	}
17
	public function addItem($item,$value=NULL,$image=NULL){
18
		return $this->getField()->addItem($item,$value,$image);
19
	}
20
	public static function multipleDropdown($identifier,$items=array(), $label=NULL,$value=NULL,$associative=true){
21
		return new HtmlFormDropdown($identifier,$items,$label,$value,true,$associative);
22
	}
23
24
	public function getDataField(){
25
		return $this->getField()->getInput();
26
	}
27
	public function asSelect($name=NULL,$multiple=false,$selection=true){
28
		$this->getField()->asSelect($name,$multiple,$selection);
29
		return $this;
30
	}
31
}