| Conditions | 12 |
| Paths | 18 |
| Total Lines | 33 |
| Code Lines | 26 |
| 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 |
||
| 28 | public static function eventCoreHeaderAddmeta($args) |
||
|
|
|||
| 29 | { |
||
| 30 | $xoops = \Xoops::getInstance(); |
||
| 31 | $sn = []; |
||
| 32 | $helper = \XoopsModules\Xoosocialnetwork\Helper::getInstance(); |
||
| 33 | if (null !== $xoops->module && is_object($xoops->module) && 'index.php' !== basename($xoops->getEnv('PHP_SELF'))) { |
||
| 34 | if (self::isActive()) { |
||
| 35 | $url = $xoops->getEnv('HTTPS') ? 'https://' : 'http://'; |
||
| 36 | $url .= $xoops->getEnv('SERVER_NAME'); |
||
| 37 | if ($xoops->getEnv('QUERY_STRING')) { |
||
| 38 | $url .= $xoops->getEnv('PHP_SELF') . '?' . urlencode($xoops->getEnv('QUERY_STRING')); |
||
| 39 | } else { |
||
| 40 | $url .= $xoops->getEnv('PHP_SELF'); |
||
| 41 | } |
||
| 42 | |||
| 43 | $socialnetworkHandler = $helper->getHandler('Socialnetwork'); |
||
| 44 | $config = $socialnetworkHandler->loadConfig(); |
||
| 45 | if (is_array($config)) { |
||
| 46 | foreach ($config as $k => $v) { |
||
| 47 | $sn[$k]['xoosocialnetwork_title'] = $v['xoosocialnetwork_title']; |
||
| 48 | $sn[$k]['xoosocialnetwork_image_link'] = $v['xoosocialnetwork_image_link']; |
||
| 49 | $sn[$k]['xoosocialnetwork_url'] = $v['xoosocialnetwork_url'] . '?'; |
||
| 50 | $sn[$k]['xoosocialnetwork_url'] .= $v['xoosocialnetwork_query_url'] . '='; |
||
| 51 | $sn[$k]['xoosocialnetwork_url'] .= $url; |
||
| 52 | if ('' != $v['xoosocialnetwork_query_title']) { |
||
| 53 | $sn[$k]['xoosocialnetwork_url'] .= '&'; |
||
| 54 | $sn[$k]['xoosocialnetwork_url'] .= $v['xoosocialnetwork_query_title'] . '='; |
||
| 55 | $sn[$k]['xoosocialnetwork_url'] .= rawurlencode($xoops->tpl()->tpl_vars['xoops_pagetitle']); |
||
| 56 | } |
||
| 57 | } |
||
| 58 | } |
||
| 59 | if (is_array($sn) && count($sn) > 0) { |
||
| 60 | $xoops->tpl()->assign('xoosocialnetwork', $sn); |
||
| 61 | } |
||
| 86 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.