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 |
||
125 | public function addCheckedList($items=array(), $masterItem=NULL, $values=array(),$notAllChecked=false,$name=null) { |
||
126 | $count=$this->count(); |
||
127 | $identifier=$this->identifier . "-" . $count; |
||
128 | if (isset($masterItem)) { |
||
129 | if(\is_array($masterItem)){ |
||
130 | $masterO=new HtmlFormCheckbox("master-" . $identifier, @$masterItem[0],@$masterItem[1]); |
||
131 | if(isset($name)) |
||
132 | $masterO->setName($name); |
||
133 | if(isset($masterItem[1])){ |
||
134 | if(\array_search($masterItem[1], $values)!==false){ |
||
135 | $masterO->getDataField()->setProperty("checked", ""); |
||
136 | } |
||
137 | } |
||
138 | }else{ |
||
139 | $masterO=new HtmlFormCheckbox("master-" . $identifier, $masterItem); |
||
140 | } |
||
141 | if($notAllChecked){ |
||
142 | $masterO->getDataField()->addClass("_notAllChecked"); |
||
143 | } |
||
144 | $masterO->getHtmlCk()->addToProperty("class", "master"); |
||
145 | $masterO->setClass("item"); |
||
146 | $this->addItem($masterO); |
||
147 | } |
||
148 | $fields=array (); |
||
149 | $i=0; |
||
150 | foreach ( $items as $val => $caption ) { |
||
151 | $itemO=new HtmlFormCheckbox($identifier . "-" . $i++, $caption, $val, "child"); |
||
152 | if (\array_search($val, $values) !== false) { |
||
153 | $itemO->getDataField()->setProperty("checked", ""); |
||
154 | } |
||
155 | if(isset($name)) |
||
156 | $itemO->setName($name); |
||
157 | $itemO->setClass("item"); |
||
158 | $fields[]=$itemO; |
||
159 | } |
||
160 | if (isset($masterO) === true) { |
||
161 | $list=new HtmlList("", $fields); |
||
162 | $list->setClass("list"); |
||
163 | $masterO->addContent($list); |
||
164 | } else { |
||
165 | $this->addList($fields); |
||
166 | } |
||
167 | $this->_hasCheckedList=true; |
||
168 | return $this; |
||
169 | } |
||
182 |