| Conditions | 9 |
| Paths | 21 |
| Total Lines | 56 |
| Code Lines | 41 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 29 | function b_xoopsheadline_show($options) |
||
|
|
|||
| 30 | { |
||
| 31 | if (!class_exists(Helper::class)) { |
||
| 32 | return false; |
||
| 33 | } |
||
| 34 | |||
| 35 | $helper = Helper::getInstance(); |
||
| 36 | |||
| 37 | $block = []; |
||
| 38 | |||
| 39 | global $xoopsConfig; |
||
| 40 | $hlDir = basename(dirname(__DIR__)); |
||
| 41 | |||
| 42 | /** @var \XoopsModuleHandler $moduleHandler */ |
||
| 43 | $moduleHandler = xoops_getHandler('module'); |
||
| 44 | $module = $moduleHandler->getByDirname($hlDir); |
||
| 45 | /** @var \XoopsConfigHandler $configHandler */ |
||
| 46 | $configHandler = xoops_getHandler('config'); |
||
| 47 | $moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
||
| 48 | |||
| 49 | $block = []; |
||
| 50 | $hlman = $helper->getHandler('Headline'); |
||
| 51 | $criteria = new \CriteriaCompo(); |
||
| 52 | $criteria->add(new \Criteria('headline_asblock', 1, '=')); |
||
| 53 | switch ($moduleConfig['sortby']) { |
||
| 54 | case 1: |
||
| 55 | $criteria->setSort('headline_name'); |
||
| 56 | $criteria->setOrder('DESC'); |
||
| 57 | break; |
||
| 58 | case 2: |
||
| 59 | $criteria->setSort('headline_name'); |
||
| 60 | $criteria->setOrder('ASC'); |
||
| 61 | break; |
||
| 62 | case 3: |
||
| 63 | $criteria->setSort('headline_weight'); |
||
| 64 | $criteria->setOrder('DESC'); |
||
| 65 | break; |
||
| 66 | case 4: |
||
| 67 | default: |
||
| 68 | $criteria->setSort('headline_weight'); |
||
| 69 | $criteria->setOrder('ASC'); |
||
| 70 | break; |
||
| 71 | } |
||
| 72 | $headlines = $hlman->getObjects($criteria); |
||
| 73 | foreach ($headlines as $i => $iValue) { |
||
| 74 | $renderer = XoopsheadlineUtility::getRenderer($headlines[$i]); |
||
| 75 | if (!$renderer->renderBlock()) { |
||
| 76 | if (2 == $xoopsConfig['debug_mode']) { |
||
| 77 | $block['feeds'][] = sprintf(_MD_HEADLINES_FAILGET, $iValue->getVar('headline_name')) . '<br>' . $renderer->getErrors(); |
||
| 78 | } |
||
| 79 | continue; |
||
| 80 | } |
||
| 81 | $block['feeds'][] = &$renderer->getBlock(); |
||
| 82 | } |
||
| 83 | |||
| 84 | return $block; |
||
| 85 | } |
||
| 86 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.