HtmlSplitbutton::run()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 10
Code Lines 7

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 10
loc 10
rs 9.4285
cc 3
eloc 7
nc 2
nop 1
1
<?php
2
3
namespace Ajax\bootstrap\html;
4
5
use Ajax\bootstrap\html\HtmlDropdown;
6
use Ajax\bootstrap\html\base\CssRef;
7
use Ajax\JsUtils;
8
9
/**
10
 * Twitter Bootstrap HTML Splitbutton component
11
 * @author jc
12
 * @version 1.001
13
 */
14
class HtmlSplitbutton extends HtmlDropdown {
15
16
	public function __construct($identifier, $value="&nbsp;", $items=array(), $cssStyle="btn-default", $onClick=null) {
17
		parent::__construct($identifier, $value, $items, $cssStyle, $onClick);
18
		$this->asButton($cssStyle);
19
		$this->_template=include 'templates/tplSplitbutton.php';
20
		$this->mClass="btn-group";
21
	}
22
23
	/**
24
	 * (non-PHPdoc)
25
	 * @see \Ajax\bootstrap\html\HtmlDropdown::setSize()
26
	 * @return HtmlSplitbutton
27
	 */
28
	public function setSize($size) {
29
		if (is_int($size)) {
30
			return $this->addToMember($this->mClass, CssRef::sizes("btn-group")[$size]);
31
		}
32
		return $this->addToMemberCtrl($this->mClass, $size, CssRef::sizes("btn-group"));
33
	}
34
35
	public function onButtonClick($jsCode) {
36
		$this->addEvent("buttonClick", $jsCode);
37
	}
38
39
	/*
40
	 * (non-PHPdoc)
41
	 * @see BaseHtml::run()
42
	 */
43 View Code Duplication
	public function run(JsUtils $js) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
44
		if ($this->getProperty("role")==="nav") {
45
			foreach ( $this->items as $dropdownItem ) {
46
				$dropdownItem->runNav($js);
47
			}
48
		}
49
		$this->_bsComponent=$js->bootstrap()->splitbutton("#".$this->identifier);
50
		$this->addEventsOnRun($js);
51
		return $this->_bsComponent;
52
	}
53
}