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