Conditions | 5 |
Paths | 6 |
Total Lines | 63 |
Code Lines | 32 |
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 |
||
147 | public function listAll() { |
||
148 | $tree = Globals::getTree(); |
||
149 | $controller = new PageController(); |
||
150 | $controller |
||
151 | ->setPageTitle(I18N::translate('Certificates')) |
||
152 | ->restrictAccess( |
||
153 | $this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($tree) |
||
154 | ); |
||
155 | |||
156 | $city = Filter::get('city'); |
||
157 | |||
158 | if(!empty($city) && strlen($city) > 22){ |
||
159 | $city = Functions::decryptFromSafeBase64($city); |
||
160 | $controller->setPageTitle(I18N::translate('Certificates for %s', $city)); |
||
161 | } |
||
162 | |||
163 | $data = new ViewBag(); |
||
164 | $data->set('title', $controller->getPageTitle()); |
||
165 | $data->set('url_module', $this->module->getName()); |
||
166 | $data->set('url_action', 'Certificate@listAll'); |
||
167 | $data->set('url_ged', $tree->getNameUrl()); |
||
168 | |||
169 | $data->set('cities', $this->provider->getCitiesList()); |
||
170 | $data->set('selected_city', $city); |
||
171 | |||
172 | $data->set('has_list', false); |
||
173 | if(!empty($city)) { |
||
174 | $table_id = 'table-certiflist-' . Uuid::uuid4(); |
||
175 | |||
176 | $certif_list = $this->provider->getCertificatesList($city); |
||
177 | if(!empty($certif_list)) { |
||
178 | $data->set('has_list', true); |
||
179 | $data->set('table_id', $table_id); |
||
180 | $data->set('certificate_list', $certif_list); |
||
181 | |||
182 | $controller |
||
183 | ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
||
184 | ->addInlineJavascript(' |
||
185 | jQuery.fn.dataTableExt.oSort["text-asc"] = textCompareAsc; |
||
186 | jQuery.fn.dataTableExt.oSort["text-desc"] = textCompareDesc; |
||
187 | |||
188 | jQuery("#'.$table_id.'").dataTable( { |
||
189 | dom: \'<"H"<"filtersH_' . $table_id . '">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_' . $table_id . '">>\', |
||
190 | '.I18N::datatablesI18N().', |
||
191 | jQueryUI: true, |
||
192 | autoWidth: false, |
||
193 | processing: true, |
||
194 | columns: [ |
||
195 | /* 0-Date */ { type: "num", width: "15%", class: "center" }, |
||
196 | /* 1-Type */ { type: "text", width: "5%", searchable: false, class: "center"}, |
||
197 | /* 2-Certificate */ { type: "text", class: "left" } |
||
198 | ], |
||
199 | sorting: [[0,"asc"], [1,"asc"]], |
||
200 | displayLength: 20, |
||
201 | pagingType: "full_numbers" |
||
202 | }); |
||
203 | jQuery(".certificate-list").css("visibility", "visible"); |
||
204 | jQuery(".loading-image").css("display", "none"); |
||
205 | '); |
||
206 | } |
||
207 | } |
||
208 | |||
209 | ViewFactory::make('CertificatesList', $this, $controller, $data)->render(); |
||
210 | |||
230 | } |
This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.