| Conditions | 11 |
| Paths | 150 |
| Total Lines | 44 |
| Code Lines | 35 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 103 | public function addCheckedList($items=array(), $masterItem=NULL, $values=array(),$notAllChecked=false,$name=null) { |
||
| 104 | $count=$this->count(); |
||
| 105 | $identifier=$this->identifier . "-" . $count; |
||
| 106 | if (isset($masterItem)) { |
||
| 107 | if(\is_array($masterItem)){ |
||
| 108 | $masterO=new HtmlFormCheckbox("master-" . $identifier, @$masterItem[0],@$masterItem[1]); |
||
| 109 | if(isset($name)) |
||
| 110 | $masterO->setName($name); |
||
| 111 | if(isset($masterItem[1])){ |
||
| 112 | if(\array_search($masterItem[1], $values)!==false){ |
||
| 113 | $masterO->getDataField()->setProperty("checked", ""); |
||
| 114 | } |
||
| 115 | } |
||
| 116 | }else{ |
||
| 117 | $masterO=new HtmlFormCheckbox("master-" . $identifier, $masterItem); |
||
| 118 | } |
||
| 119 | if($notAllChecked){ |
||
| 120 | $masterO->getDataField()->addClass("_notAllChecked"); |
||
| 121 | } |
||
| 122 | $masterO->getHtmlCk()->addToProperty("class", "master"); |
||
| 123 | $masterO->setClass("item"); |
||
| 124 | $this->addItem($masterO); |
||
| 125 | } |
||
| 126 | $fields=array (); |
||
| 127 | $i=0; |
||
| 128 | foreach ( $items as $val => $caption ) { |
||
| 129 | $itemO=new HtmlFormCheckbox($identifier . "-" . $i++, $caption, $val, "child"); |
||
| 130 | if (\array_search($val, $values) !== false) { |
||
| 131 | $itemO->getDataField()->setProperty("checked", ""); |
||
| 132 | } |
||
| 133 | if(isset($name)) |
||
| 134 | $itemO->setName($name); |
||
| 135 | $itemO->setClass("item"); |
||
| 136 | $fields[]=$itemO; |
||
| 137 | } |
||
| 138 | if (isset($masterO) === true) { |
||
| 139 | $list=new HtmlList("", $fields); |
||
| 140 | $list->setClass("list"); |
||
| 141 | $masterO->addContent($list); |
||
| 142 | } else { |
||
| 143 | $this->addList($fields); |
||
| 144 | } |
||
| 145 | $this->_hasCheckedList=true; |
||
| 146 | return $this; |
||
| 147 | } |
||
| 160 |