| Conditions | 22 |
| Paths | 18432 |
| Total Lines | 104 |
| Code Lines | 69 |
| 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 |
||
| 250 | public function generatePage(Page $P) |
||
| 251 | { |
||
| 252 | $requesturi = $this->serviceManager->get('request')->getRequestTarget(); |
||
| 253 | |||
| 254 | $aP = [ |
||
| 255 | 'language' => HelperConfig::$lang, |
||
| 256 | 'pageconfig' => $P->cb_pageconfig, |
||
| 257 | 'pagetype' => $P->cb_pagetype, |
||
| 258 | 'subnavkey' => $P->cb_subnav, |
||
| 259 | 'requesturi' => $requesturi, |
||
| 260 | 'requesturiarray' => parse_url($requesturi), |
||
| 261 | 'locale_format_date' => HelperConfig::$core['locale_format_date'], |
||
| 262 | 'locale_format_date_time' => HelperConfig::$core['locale_format_date_time'], |
||
| 263 | 'maintenancemode' => HelperConfig::$core['maintenancemode'], |
||
| 264 | 'numberformat_decimals' => HelperConfig::$core['numberformat_decimals'], |
||
| 265 | 'numberformat_decimal_point' => HelperConfig::$core['numberformat_decimal_point'], |
||
| 266 | 'numberformat_thousands_seperator' => HelperConfig::$core['numberformat_thousands_seperator'], |
||
| 267 | 'customroottemplate' => $P->getCustomRootTemplate(), |
||
| 268 | 'headers' => $P->getHeaders(), |
||
| 269 | ]; |
||
| 270 | if (HelperConfig::$core['enable_module_customer']) { |
||
| 271 | $aP['isloggedin'] = \HaaseIT\HCSF\Customer\Helper::getUserData(); |
||
| 272 | $aP['enable_module_customer'] = true; |
||
| 273 | } |
||
| 274 | if (HelperConfig::$core['enable_module_shop']) { |
||
| 275 | $aP['currency'] = HelperConfig::$shop['waehrungssymbol']; |
||
| 276 | $aP['orderamounts'] = HelperConfig::$shop['orderamounts']; |
||
| 277 | if (isset(HelperConfig::$shop['vat']['full'])) { |
||
| 278 | $aP['vatfull'] = HelperConfig::$shop['vat']['full']; |
||
| 279 | } |
||
| 280 | if (isset(HelperConfig::$shop['vat']['reduced'])) { |
||
| 281 | $aP['vatreduced'] = HelperConfig::$shop['vat']['reduced']; |
||
| 282 | } |
||
| 283 | if (isset(HelperConfig::$shop['custom_order_fields'])) { |
||
| 284 | $aP['custom_order_fields'] = HelperConfig::$shop['custom_order_fields']; |
||
| 285 | } |
||
| 286 | $aP['enable_module_shop'] = true; |
||
| 287 | } |
||
| 288 | if (isset($P->cb_key)) { |
||
| 289 | $aP['path'] = pathinfo($P->cb_key); |
||
| 290 | } else { |
||
| 291 | $aP['path'] = pathinfo($aP['requesturi']); |
||
| 292 | } |
||
| 293 | if ($P->cb_customcontenttemplate != NULL) { |
||
| 294 | $aP['customcontenttemplate'] = $P->cb_customcontenttemplate; |
||
| 295 | } |
||
| 296 | if ($P->cb_customdata != NULL) { |
||
| 297 | $aP['customdata'] = $P->cb_customdata; |
||
| 298 | } |
||
| 299 | if (isset($_SERVER['HTTP_REFERER'])) { |
||
| 300 | $aP['referer'] = $_SERVER['HTTP_REFERER']; |
||
| 301 | } |
||
| 302 | |||
| 303 | // if there is no subnav defined but there is a default subnav defined, use it |
||
| 304 | // subnavkey can be used in the templates to find out, where we are |
||
| 305 | if ((!isset($aP['subnavkey']) || $aP['subnavkey'] == '') && HelperConfig::$core['subnav_default'] != '') { |
||
| 306 | $aP['subnavkey'] = HelperConfig::$core['subnav_default']; |
||
| 307 | $P->cb_subnav = HelperConfig::$core['subnav_default']; |
||
| 308 | } |
||
| 309 | if ($P->cb_subnav != NULL && isset(HelperConfig::$navigation[$P->cb_subnav])) { |
||
| 310 | $aP['subnav'] = HelperConfig::$navigation[$P->cb_subnav]; |
||
| 311 | } |
||
| 312 | |||
| 313 | // Get page title, meta-keywords, meta-description |
||
| 314 | $aP['pagetitle'] = $P->oPayload->getTitle(); |
||
| 315 | $aP['keywords'] = $P->oPayload->cl_keywords; |
||
| 316 | $aP['description'] = $P->oPayload->cl_description; |
||
| 317 | |||
| 318 | // Shopping cart infos |
||
| 319 | if (HelperConfig::$core['enable_module_shop']) { |
||
| 320 | $aP['cartinfo'] = SHelper::getShoppingcartData(); |
||
| 321 | } |
||
| 322 | |||
| 323 | $aP['countrylist'][] = ' | '; |
||
| 324 | foreach (HelperConfig::$countries['countries_' .HelperConfig::$lang] as $sKey => $sValue) { |
||
| 325 | $aP['countrylist'][] = $sKey.'|'.$sValue; |
||
| 326 | } |
||
| 327 | |||
| 328 | if ( |
||
| 329 | HelperConfig::$core['enable_module_shop'] |
||
| 330 | && ( |
||
| 331 | $aP['pagetype'] === 'itemoverview' |
||
| 332 | || $aP['pagetype'] === 'itemoverviewgrpd' |
||
| 333 | || $aP['pagetype'] === 'itemdetail' |
||
| 334 | ) |
||
| 335 | ) { |
||
| 336 | $aP = SHelper::handleItemPage($this->serviceManager, $P, $aP); |
||
| 337 | } |
||
| 338 | |||
| 339 | $aP['content'] = $P->oPayload->cl_html; |
||
| 340 | |||
| 341 | $aP['content'] = str_replace('@', '@', $aP['content']); // Change @ to HTML Entity -> maybe less spam mails |
||
| 342 | |||
| 343 | $aP['lang_available'] = HelperConfig::$core['lang_available']; |
||
| 344 | $aP['lang_detection_method'] = HelperConfig::$core['lang_detection_method']; |
||
| 345 | $aP['lang_by_domain'] = HelperConfig::$core['lang_by_domain']; |
||
| 346 | |||
| 347 | if (HelperConfig::$core['debug']) { |
||
| 348 | \HaaseIT\HCSF\Helper::getDebug($aP, $P); |
||
| 349 | $aP['debugdata'] = \HaaseIT\Toolbox\Tools::$sDebug; |
||
| 350 | } |
||
| 351 | |||
| 352 | return $aP; |
||
| 353 | } |
||
| 354 | } |
||
| 355 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.