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