| Conditions | 5 |
| Paths | 4 |
| Total Lines | 51 |
| Code Lines | 28 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | 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); |
||
| 35 | function b_wgevents_event_spotlight_show($options) |
||
| 36 | { |
||
| 37 | $block = []; |
||
| 38 | $typeBlock = $options[0]; |
||
|
|
|||
| 39 | $limit = $options[1]; |
||
| 40 | $lengthTitle = $options[2]; |
||
| 41 | $helper = Helper::getInstance(); |
||
| 42 | $eventHandler = $helper->getHandler('Event'); |
||
| 43 | $crEvent = new \CriteriaCompo(); |
||
| 44 | \array_shift($options); |
||
| 45 | \array_shift($options); |
||
| 46 | \array_shift($options); |
||
| 47 | |||
| 48 | $eventRegprocessbar = (string)$helper->getConfig('event_regprocessbar'); |
||
| 49 | $GLOBALS['xoopsTpl']->assign('event_regprocessbar', $eventRegprocessbar); |
||
| 50 | |||
| 51 | // Criteria for status field |
||
| 52 | $crEvent->add(new \Criteria('status', Constants::STATUS_SUBMITTED, '>')); |
||
| 53 | |||
| 54 | if (\count($options) > 0 && (int)$options[0] > 0) { |
||
| 55 | $crEvent->add(new \Criteria('id', '(' . \implode(',', $options) . ')', 'IN')); |
||
| 56 | $limit = 0; |
||
| 57 | } |
||
| 58 | |||
| 59 | $crEvent->setSort('id'); |
||
| 60 | $crEvent->setOrder('DESC'); |
||
| 61 | $crEvent->setLimit($limit); |
||
| 62 | $eventsAll = $eventHandler->getAll($crEvent); |
||
| 63 | unset($crEvent); |
||
| 64 | if (\count($eventsAll) > 0) { |
||
| 65 | foreach (\array_keys($eventsAll) as $i) { |
||
| 66 | /** |
||
| 67 | * If you want to use the parameter for limits you have to adapt the line where it should be applied |
||
| 68 | * e.g. change |
||
| 69 | * $block[$i]['title'] = $eventsAll[$i]->getVar('art_title'); |
||
| 70 | * into |
||
| 71 | * $myTitle = $eventsAll[$i]->getVar('art_title'); |
||
| 72 | * if ($limit > 0) { |
||
| 73 | * $myTitle = \substr($myTitle, 0, (int)$limit); |
||
| 74 | * } |
||
| 75 | * $block[$i]['title'] = $myTitle; |
||
| 76 | */ |
||
| 77 | $block[$i] = $eventsAll[$i]->getValuesEvents(); |
||
| 78 | } |
||
| 79 | } |
||
| 80 | |||
| 81 | $GLOBALS['xoopsTpl']->assign('wgevents_upload_catlogos_url', \WGEVENTS_UPLOAD_CATLOGOS_URL); |
||
| 82 | $GLOBALS['xoopsTpl']->assign('wgevents_upload_eventlogos_url', \WGEVENTS_UPLOAD_EVENTLOGOS_URL); |
||
| 83 | $GLOBALS['xoopsTpl']->assign('wgevents_url', \WGEVENTS_URL . '/'); |
||
| 84 | |||
| 85 | return $block; |
||
| 86 | |||
| 124 |