| Conditions | 7 |
| Paths | 9 |
| Total Lines | 75 |
| Code Lines | 39 |
| 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); |
||
| 144 | public function storeFaq(Xhelp\Faq $faq = null): bool |
||
| 145 | { |
||
| 146 | global $xoopsUser, $publisher_itemHandler; |
||
| 147 | |||
| 148 | $uid = $xoopsUser->getVar('uid'); |
||
| 149 | |||
| 150 | // if (!\class_exists('XoopsModules\Publisher\Helper')) { |
||
| 151 | // return false; |
||
| 152 | // } |
||
| 153 | if (null === $this->helper) { |
||
| 154 | return false; |
||
| 155 | } |
||
| 156 | |||
| 157 | $this->helper->loadLanguage('admin'); |
||
| 158 | |||
| 159 | //fix for publisherItem::store assuming that publisher handlers are globalized //TODO MB adjust for Publisher |
||
| 160 | $publisherItemHandler = $this->helper->getHandler('Item'); |
||
| 161 | $publisherCategoryHandler = $this->helper->getHandler('Category'); |
||
| 162 | |||
| 163 | // $ssConfig = XoopsModules\Publisher\Utility::getModuleConfig(); |
||
| 164 | |||
| 165 | // Create page in publisher from Xhelp\Faq object |
||
| 166 | /** @var \XoopsModules\Publisher\Item $itemObj */ |
||
| 167 | $itemObj = $publisherItemHandler->create(); |
||
| 168 | |||
| 169 | //$faq->getVar('categories') is an array. If your application |
||
| 170 | //only supports single categories use the first element |
||
| 171 | //in the array |
||
| 172 | $categories = $faq->getVar('categories'); |
||
| 173 | $categories = (int)$categories[0]; // Change array of categories to 1 category |
||
| 174 | |||
| 175 | // Putting the values about the ITEM in the ITEM object |
||
| 176 | $itemObj->setVar('categoryid', $categories); |
||
| 177 | $itemObj->setVar('title', $faq->getVar('subject', 'e')); |
||
| 178 | $itemObj->setVar('summary', '[b]' . \ucfirst(\_XHELP_TEXT_PROBLEM) . "[/b]\r\n" . $faq->getVar('problem', 'e')); |
||
| 179 | $itemObj->setVar('body', '[b]' . \ucfirst(\_XHELP_TEXT_SOLUTION) . "[/b]\r\n" . $faq->getVar('solution', 'e')); |
||
| 180 | |||
| 181 | $itemObj->setVar('dohtml', \XHELP_SSECTION_DOHTML); |
||
| 182 | $itemObj->setVar('dosmiley', \XHELP_SSECTION_DOSMILEY); |
||
| 183 | $itemObj->setVar('doxcode', \XHELP_SSECTION_DOBBCODE); |
||
| 184 | $itemObj->setVar('doimage', \XHELP_SSECTION_DOIMAGE); |
||
| 185 | $itemObj->setVar('dobr', \XHELP_SSECTION_DOBR); |
||
| 186 | $itemObj->setVar('notifypub', \XHELP_SSECTION_NOTIFYPUB); |
||
| 187 | $itemObj->setVar('uid', $uid); |
||
| 188 | $itemObj->setVar('datesub', \time()); |
||
| 189 | |||
| 190 | // Setting the status of the item |
||
| 191 | if ($this->articleNeedsApproval()) { |
||
| 192 | $itemObj->setVar('status', Constants::PUBLISHER_STATUS_SUBMITTED); |
||
| 193 | } else { |
||
| 194 | $itemObj->setVar('status', Constants::PUBLISHER_STATUS_PUBLISHED); |
||
| 195 | } |
||
| 196 | |||
| 197 | // Storing the item object in the database |
||
| 198 | $ret = $itemObj->store(); |
||
| 199 | if ($ret && null !== $faq) { |
||
| 200 | $faq->setVar('id', $itemObj->getVar('itemid')); |
||
| 201 | $faq->setVar('url', $this->makeFaqUrl($faq)); |
||
| 202 | |||
| 203 | if ($this->articleNeedsApproval()) { |
||
| 204 | if (\XHELP_SSECTION_NOTIFYPUB) { |
||
| 205 | require_once XOOPS_ROOT_PATH . '/include/notification_constants.php'; |
||
| 206 | /** @var \XoopsNotificationHandler $notificationHandler */ |
||
| 207 | $notificationHandler = \xoops_getHandler('notification'); |
||
| 208 | $notificationHandler->subscribe('item', $itemObj->itemid(), 'approved', \XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE); |
||
| 209 | } |
||
| 210 | // Send notifications |
||
| 211 | $itemObj->sendNotifications([\_AM_PUBLISHER_NOITEMS_SUBMITTED]); |
||
| 212 | } else { |
||
| 213 | // Send notifications |
||
| 214 | $itemObj->sendNotifications([\_AM_PUBLISHER_NOITEMS]); |
||
| 215 | } |
||
| 216 | } |
||
| 217 | |||
| 218 | return $ret; |
||
| 219 | } |
||
| 242 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths