| Conditions | 10 |
| Paths | 96 |
| Total Lines | 52 |
| Code Lines | 41 |
| 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 declare(strict_types=1); |
||
| 75 | public function getValuesAnswerhists($questionsArr, $keys = null, $format = null, $maxDepth = null) |
||
| 76 | { |
||
| 77 | $helper = \XoopsModules\Wgevents\Helper::getInstance(); |
||
| 78 | $ret = $this->getValues($keys, $format, $maxDepth); |
||
| 79 | $ret['hist_datecreated_text'] = \formatTimestamp($this->getVar('hist_datecreated'), 's'); |
||
| 80 | $ret['hist_submitter_text'] = \XoopsUser::getUnameFromId($this->getVar('hist_submitter')); |
||
| 81 | $questionHandler = $helper->getHandler('Question'); |
||
| 82 | $questionObj = $questionHandler->get($this->getVar('queid')); |
||
| 83 | $queCaption = ''; |
||
| 84 | if (\is_object($questionObj)) { |
||
| 85 | $queCaption = $questionObj->getVar('caption'); |
||
| 86 | } |
||
| 87 | $ret['quecaption'] = $queCaption; |
||
| 88 | $queItem = $questionsArr[$this->getVar('queid')]; |
||
| 89 | $ansText = $this->getVar('text', 'n'); |
||
| 90 | if (Constants::FIELD_RADIOYN == $queItem['type']) { |
||
| 91 | if ((bool)$ansText) { |
||
| 92 | $ansText = \_YES; |
||
| 93 | } else { |
||
| 94 | $ansText = \_NO; |
||
| 95 | } |
||
| 96 | } |
||
| 97 | if (Constants::FIELD_CHECKBOX == $queItem['type'] || |
||
| 98 | Constants::FIELD_COMBOBOX == $queItem['type']) { |
||
| 99 | $queValues = \unserialize($queItem['values'], ['allowed_classes' => false]); |
||
| 100 | $ansItems = \unserialize($ansText, ['allowed_classes' => false]); |
||
| 101 | $ansText = ''; |
||
| 102 | foreach ($ansItems as $ansItem) { |
||
| 103 | $ansText .= $queValues[(int)$ansItem] . ' <br>'; |
||
| 104 | } |
||
| 105 | } |
||
| 106 | if (Constants::FIELD_SELECTBOX == $queItem['type']) { |
||
| 107 | $queValues = \unserialize($queItem['values'], ['allowed_classes' => false]); |
||
| 108 | $ansItem = (string)\unserialize($ansText, ['allowed_classes' => false]); |
||
| 109 | $ansText = $queValues[(int)$ansItem]; |
||
| 110 | } |
||
| 111 | if (Constants::FIELD_RADIO == $queItem['type']) { |
||
| 112 | $queValues = \unserialize($queItem['values']); |
||
| 113 | $ansText = $queValues[$ansText]; |
||
| 114 | } |
||
| 115 | $ret['text_text'] = $ansText; |
||
| 116 | $eventHandler = $helper->getHandler('Event'); |
||
| 117 | $eventObj = $eventHandler->get($this->getVar('evid')); |
||
| 118 | $evName = 'invalid event'; |
||
| 119 | if (\is_object($eventObj)) { |
||
| 120 | $evName = $eventObj->getVar('name'); |
||
| 121 | } |
||
| 122 | $ret['eventname'] = $evName; |
||
| 123 | $ret['datecreated_text'] = \formatTimestamp($this->getVar('datecreated'), 's'); |
||
| 124 | $ret['submitter_text'] = \XoopsUser::getUnameFromId($this->getVar('submitter')); |
||
| 125 | |||
| 126 | return $ret; |
||
| 127 | } |
||
| 129 |