Completed
Push — master ( 012895...9e0835 )
by Jean-Christophe
03:33
created

AbstractHtmlFormRadioCheckbox   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 2
A setType() 0 3 1
A getInput() 0 3 1
A setInput() 0 4 1
A setReadonly() 0 4 1
1
<?php
2
3
namespace Ajax\semantic\html\collections\form;
4
5
use Ajax\semantic\html\collections\form\HtmlFormInput;
6
use Ajax\semantic\html\base\constants\CheckboxType;
7
/**
8
 * Abstract class for Semantic Radio and Checkbox
9
 * @author jc
10
 * @version 1.001
11
 */
12
abstract class AbstractHtmlFormRadioCheckbox extends HtmlFormField {
13
	protected $_input;
14
15
	public function __construct($identifier, $name=NULL,$label=NULL,$value=NULL,$type=NULL) {
16
		$input=new HtmlFormInput($identifier,$label,"checkbox",$value);
17
		parent::__construct("rField-".$identifier, $input);
18
		if(isset($label)){
19
			$input->swapLabel();
20
			$label=$input->getLabel();
21
			$label->setClass="hidden";
22
			$label->setProperty("tabindex",0);
23
		}
24
		$this->_input=$input;
25
		$input->getField()->addToProperty("class","hidden");
26
	}
27
28
	public function setType($checkboxType){
29
		return $this->_input->addToPropertyCtrl("class", $checkboxType, CheckboxType::getConstants());
30
	}
31
32
	public function getInput() {
33
		return $this->_input;
34
	}
35
36
	public function setInput($_input) {
37
		$this->_input=$_input;
38
		return $this;
39
	}
40
41
	public function setReadonly(){
42
		$this->_input->getField()->setProperty("disabled","disabled");
43
		return $this->_input->addToProperty("class","read-only");
44
	}
45
46
}