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