| Conditions | 7 |
| Paths | 4 |
| Total Lines | 55 |
| Code Lines | 42 |
| 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); |
||
| 38 | function b_marquee_catads($limit, $dateFormat, $itemsSize) |
||
| 39 | { |
||
| 40 | global $xoopsModule, $xoopsModuleConfig, $xoopsDB; |
||
| 41 | // require_once XOOPS_ROOT_PATH . '/modules/catads/class/cat.php'; |
||
| 42 | $block = []; |
||
| 43 | if (empty($xoopsModule) || 'catads' !== $xoopsModule->getVar('dirname')) { |
||
| 44 | /** @var \XoopsModuleHandler $moduleHandler */ |
||
| 45 | $moduleHandler = xoops_getHandler('module'); |
||
| 46 | $module = $moduleHandler->getByDirname('catads'); |
||
| 47 | /** @var \XoopsConfigHandler $configHandler */ |
||
| 48 | $configHandler = xoops_getHandler('config'); |
||
| 49 | $config = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
||
| 50 | } else { |
||
| 51 | $module = $xoopsModule; |
||
| 52 | $config = $xoopsModuleConfig; |
||
| 53 | } |
||
| 54 | //echo '<br>ok'; |
||
| 55 | $ads_hnd = Catads\Helper::getInstance()->getHandler('Ads'); |
||
| 56 | $criteria = new \CriteriaCompo(new \Criteria('waiting', '0')); |
||
| 57 | $criteria->add(new \Criteria('published', time(), '<')); |
||
| 58 | $criteria->add(new \Criteria('expired', time(), '>')); |
||
| 59 | $criteria->setSort('published'); |
||
| 60 | $criteria->setOrder('DESC'); |
||
| 61 | $criteria->setLimit($limit); |
||
| 62 | $nbads = $ads_hnd->getCount($criteria); |
||
| 63 | $itemArray = []; |
||
| 64 | $catBuffer = []; |
||
| 65 | if ($nbads > 0) { |
||
| 66 | $ads = $ads_hnd->getObjects($criteria); |
||
| 67 | $myts = \MyTextSanitizer::getInstance(); |
||
| 68 | foreach ($ads as $oneads) { |
||
| 69 | if ($itemsSize > 0) { |
||
| 70 | $title = xoops_substr($oneads->getVar('ads_title'), 0, $itemsSize); |
||
| 71 | } else { |
||
| 72 | $title = $oneads->getVar('ads_title'); |
||
| 73 | } |
||
| 74 | if (!isset($catBuffer[$oneads->getVar('cat_id')])) { |
||
| 75 | $tmpcat = new Catads\AdsCategory($oneads->getVar('cat_id')); |
||
| 76 | $catBuffer[$oneads->getVar('cat_id')] = $tmpcat->title(); |
||
| 77 | $catTitle = $tmpcat->title(); |
||
| 78 | } else { |
||
| 79 | $catTitle = $catBuffer[$oneads->getVar('cat_id')]; |
||
| 80 | } |
||
| 81 | $block[] = [ |
||
| 82 | 'date' => formatTimestamp($oneads->getVar('published'), $dateFormat), |
||
| 83 | 'category' => '', |
||
| 84 | 'author' => \XoopsUser::getUnameFromId($oneads->getVar('uid')), |
||
| 85 | 'title' => $title, |
||
| 86 | 'link' => "<a href='" . XOOPS_URL . '/modules/catads/adsitem.php?ads_id=' . $oneads->getVar('ads_id') . "'>" . $title . '</a>', |
||
| 87 | ]; |
||
| 88 | unset($itemArray); |
||
| 89 | } |
||
| 90 | } |
||
| 91 | |||
| 92 | return $block; |
||
| 93 | } |
||
| 94 |
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